/* Цвета берём из темы Telegram (переменные --tg-theme-* выставляет telegram-web-app.js).
   Значения после запятой — запасные, для отладки в обычном браузере. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #efeff4);
  --section: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --accent: var(--tg-theme-accent-text-color, var(--btn));
  --destructive: var(--tg-theme-destructive-text-color, #e53935);
  --separator: var(--tg-theme-section-separator-color, rgba(60, 60, 67, 0.18));
  --section-header: var(--tg-theme-section-header-text-color, #6d6d72);
  --subtitle: var(--tg-theme-subtitle-text-color, var(--hint));
  --fill: color-mix(in srgb, var(--hint) 14%, transparent);
  --ok: #34a853;
  --warn: #e8a100;
  --radius: 12px;
  --gutter: 16px;
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

@media (prefers-color-scheme: dark) {
  html.no-tg {
    --bg: #000000;
    --section: #1c1c1e;
    --text: #ffffff;
    --hint: #98989e;
    --link: #3e88f7;
    --btn: #3e88f7;
    --accent: #3e88f7;
    --separator: rgba(84, 84, 88, 0.6);
    --section-header: #8d8e93;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, 'SF Pro Text', Roboto, 'Segoe UI', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  padding-top: var(--safe-top);
  min-height: var(--tg-viewport-height, 100vh);
}

body.has-fallback-bar {
  padding-bottom: calc(76px + var(--safe-bottom));
}

main {
  padding-bottom: 24px;
}

a {
  color: var(--link);
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3 {
  margin: 0;
}

code {
  font-size: 13px;
  background: var(--fill);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ---------- Секции и ячейки (как в интерфейсе Telegram) ---------- */

.section {
  background: var(--section);
  border-radius: var(--radius);
  margin: 0 var(--gutter) 16px;
  overflow: hidden;
}

.section.pad {
  padding: 14px 16px;
}

.section-header {
  margin: 20px calc(var(--gutter) + 16px) 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--section-header);
}

.section-footer {
  margin: -10px calc(var(--gutter) + 16px) 16px;
  font-size: 13px;
  color: var(--hint);
}

.cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 16px;
  position: relative;
  color: var(--text);
  width: 100%;
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
}

button.cell,
a.cell {
  cursor: pointer;
}

button.cell:active,
a.cell:active {
  background: var(--fill);
}

.cell + .cell::before {
  content: '';
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  border-top: 0.5px solid var(--separator);
}

.cell-main {
  flex: 1;
  min-width: 0;
}

.cell-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-sub {
  font-size: 14px;
  color: var(--subtitle);
  margin-top: 2px;
}

.cell-value {
  color: var(--hint);
  text-align: right;
}

.cell-chevron {
  width: 18px;
  height: 18px;
  color: var(--hint);
  flex: none;
}

.cell.destructive {
  color: var(--destructive);
  justify-content: center;
}

.cell.accent {
  color: var(--accent);
}

.counter {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Поля ввода ---------- */

.field {
  display: block;
  padding: 8px 16px 10px;
  position: relative;
}

.field + .field::before,
.field-row + .field::before,
.field + .field-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  border-top: 0.5px solid var(--separator);
}

.field-label {
  display: block;
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 2px;
}

.field input,
.field textarea {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  padding: 2px 0;
  resize: none;
}

.field textarea {
  min-height: 72px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: color-mix(in srgb, var(--hint) 70%, transparent);
}

.field-row {
  display: flex;
  position: relative;
}

.field-row .field {
  flex: 1;
  min-width: 0;
}

.field-row .field + .field::before {
  top: 8px;
  bottom: 8px;
  left: 0;
  right: auto;
  border-top: 0;
  border-left: 0.5px solid var(--separator);
}

/* ---------- Сегменты и чипы ---------- */

.segmented {
  display: flex;
  gap: 2px;
  padding: 2px;
  margin: 0 var(--gutter) 16px;
  background: var(--fill);
  border-radius: 9px;
}

.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 6px;
  border-radius: 7px;
  cursor: pointer;
}

.segmented button.active {
  background: var(--section);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.segmented.in-section {
  margin: 10px 16px;
}

.segmented[aria-disabled='true'] {
  opacity: 0.5;
  pointer-events: none;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 var(--gutter) 12px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  border: 0;
  background: var(--section);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  height: 32px;
  padding: 0 14px;
  border-radius: 16px;
  cursor: pointer;
}

.chip .n {
  color: var(--hint);
  margin-left: 4px;
}

.chip.active {
  background: var(--btn);
  color: var(--btn-text);
}

.chip.active .n {
  color: inherit;
  opacity: 0.75;
}

/* ---------- Бейджи ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--fill);
  color: var(--hint);
}

.badge-ok {
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  color: var(--ok);
}

.badge-warn {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: color-mix(in srgb, var(--warn) 85%, var(--text));
}

.badge-accent {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}

.badge-danger {
  background: color-mix(in srgb, var(--destructive) 14%, transparent);
  color: var(--destructive);
}

/* ---------- Шапка галереи ---------- */

.hero {
  text-align: center;
  padding: 20px var(--gutter) 16px;
}

.avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--btn) 70%, #fff), var(--btn));
  color: #fff;
  font-size: 34px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.hero .city {
  color: var(--hint);
  font-size: 15px;
  margin-top: 2px;
}

.hero .desc {
  margin: 10px auto 0;
  max-width: 480px;
  font-size: 15px;
  color: var(--subtitle);
  white-space: pre-line;
}

.owner-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 var(--gutter) 16px;
}

.owner-tile {
  position: relative;
  background: var(--section);
  border-radius: var(--radius);
  padding: 12px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.owner-tile svg {
  width: 26px;
  height: 26px;
  color: var(--accent);
}

.owner-tile .counter {
  position: absolute;
  top: 8px;
  right: 8px;
}

.owner-tile:active {
  opacity: 0.7;
}

/* ---------- Сетка работ ---------- */

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

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.card {
  display: block;
  background: var(--section);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--text);
  transition: transform 0.12s ease;
}

.card:active {
  transform: scale(0.97);
}

.card-img {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--fill);
}

.card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-img .noimg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  opacity: 0.5;
}

.card-img .badge {
  position: absolute;
  left: 8px;
  top: 8px;
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--section) 82%, transparent);
}

.card.is-sold .card-img img {
  filter: grayscale(0.6);
  opacity: 0.7;
}

.card-body {
  padding: 8px 10px 10px;
}

.card-title {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-price {
  font-size: 14px;
  font-weight: 600;
  margin-top: 2px;
}

/* ---------- Страница работы ---------- */

.carousel {
  position: relative;
  background: var(--section);
  margin-bottom: 12px;
}

.carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.carousel-track::-webkit-scrollbar {
  display: none;
}

.carousel-track img {
  flex: none;
  width: 100%;
  height: min(78vh, 520px);
  object-fit: contain;
  scroll-snap-align: center;
  background: var(--section);
  cursor: zoom-in;
}

.carousel-empty {
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  opacity: 0.4;
}

.dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.dots span {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.5);
  transition: width 0.2s;
}

.dots span.on {
  width: 16px;
  background: #fff;
}

.art-head h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.art-price {
  font-size: 20px;
  font-weight: 600;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.art-desc {
  white-space: pre-line;
  font-size: 15px;
}

.banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 15px;
}

.banner .ico {
  font-size: 22px;
  line-height: 1;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pinch-zoom;
}

.viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.viewer-close {
  position: absolute;
  top: calc(12px + var(--safe-top));
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 18px;
  border: 0;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 8px;
}

/* ---------- Заявки ---------- */

.req-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
}

.thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--fill);
  flex: none;
}

.req-lines {
  padding: 0 16px 12px;
  font-size: 15px;
  display: grid;
  gap: 4px;
}

.req-lines .k {
  color: var(--hint);
}

.req-actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 14px;
  flex-wrap: wrap;
}

/* ---------- Кнопки внутри страницы ---------- */

.btn {
  border: 0;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 auto;
}

.btn:disabled {
  opacity: 0.5;
}

.btn-primary {
  background: var(--btn);
  color: var(--btn-text);
}

.btn-secondary {
  background: color-mix(in srgb, var(--btn) 12%, transparent);
  color: var(--accent);
}

.btn-danger {
  background: color-mix(in srgb, var(--destructive) 12%, transparent);
  color: var(--destructive);
}

.btn-small {
  height: 32px;
  font-size: 14px;
  flex: none;
}

/* ---------- Фото в редакторе ---------- */

.photos {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px;
}

.photo-tile {
  position: relative;
  flex: none;
  width: 92px;
  height: 92px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--fill);
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-tile .cover-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 11px;
  text-align: center;
  padding: 2px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
}

.photo-tile .tile-btn {
  position: absolute;
  top: 4px;
  width: 24px;
  height: 24px;
  border-radius: 12px;
  border: 0;
  padding: 5px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
}

.photo-tile .tile-btn.del {
  right: 4px;
}

.photo-tile .tile-btn.left {
  left: 4px;
}

.photo-tile.uploading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.photo-tile.uploading .spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  z-index: 1;
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
}

.photo-add {
  flex: none;
  width: 92px;
  height: 92px;
  border-radius: 10px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 60%, transparent);
  color: var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.photo-add svg {
  width: 26px;
  height: 26px;
}

.photo-add input {
  display: none;
}

/* ---------- Каналы и публикация ---------- */

.check {
  width: 22px;
  height: 22px;
  border-radius: 11px;
  border: 1.5px solid var(--hint);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.check.on {
  background: var(--btn);
  border-color: var(--btn);
}

.check.on::after {
  content: '';
  width: 6px;
  height: 11px;
  border: solid var(--btn-text);
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}

.ch-avatar {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  flex: none;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.post-preview {
  padding: 12px 16px 14px;
}

.post-bubble {
  max-width: 320px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg);
}

.post-bubble img {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
}

.post-bubble .txt {
  padding: 8px 12px 10px;
  font-size: 15px;
  white-space: pre-line;
}

.post-bubble .kb {
  margin: 4px;
  padding: 9px;
  text-align: center;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  background: color-mix(in srgb, var(--hint) 22%, transparent);
}

/* ---------- Имитация оплаты ---------- */

.pay-sheet {
  text-align: center;
  padding: 28px 24px 24px;
}

.pay-star {
  font-size: 64px;
  line-height: 1;
  filter: drop-shadow(0 6px 16px rgba(255, 170, 0, 0.45));
}

.pay-sheet h2 {
  margin-top: 14px;
  font-size: 24px;
}

.pay-sheet p {
  color: var(--subtitle);
  margin: 8px 0 0;
}

.test-note {
  display: inline-block;
  margin-top: 16px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  color: color-mix(in srgb, var(--warn) 80%, var(--text));
}

/* ---------- Служебное ---------- */

.placeholder {
  text-align: center;
  padding: 56px 32px;
}

.placeholder-icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 14px;
}

.placeholder-title {
  font-size: 19px;
  font-weight: 600;
}

.placeholder-text {
  color: var(--hint);
  margin-top: 6px;
  font-size: 15px;
}

.placeholder .btn {
  margin-top: 18px;
  flex: none;
}

.loader {
  display: flex;
  justify-content: center;
  padding: 80px 0;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--fill);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--fill) 0%, color-mix(in srgb, var(--hint) 6%, transparent) 50%, var(--fill) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.toast {
  position: fixed;
  left: 50%;
  top: calc(12px + var(--safe-top));
  transform: translate(-50%, -140%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--text) 88%, transparent);
  color: var(--section);
  font-size: 14px;
  font-weight: 500;
  z-index: 100;
  transition: transform 0.25s ease;
  pointer-events: none;
}

.toast.show {
  transform: translate(-50%, 0);
}

.muted {
  color: var(--hint);
}

.small {
  font-size: 13px;
}

.fallback-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  gap: 8px;
  padding: 10px var(--gutter) calc(10px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 0.5px solid var(--separator);
}

.fb-btn {
  flex: 1;
  height: 50px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.fb-main {
  background: var(--btn);
  color: var(--btn-text);
}

.fb-secondary {
  background: var(--section);
  color: var(--accent);
}

.fb-btn:disabled {
  opacity: 0.55;
}

.fallback-back {
  position: sticky;
  top: 0;
  z-index: 30;
  display: block;
  border: 0;
  background: var(--bg);
  color: var(--link);
  font: inherit;
  font-size: 17px;
  padding: 10px var(--gutter);
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.fallback-back[hidden],
.fallback-bar[hidden],
.dev-hint[hidden] {
  display: none;
}

.dev-hint {
  margin: 12px var(--gutter) 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}
