/* Общая адаптивность Mini App: телефон / планшет / десктоп */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

:root {
  --tg-sa-top: 0px;
  --tg-sa-right: 0px;
  --tg-sa-left: 0px;
  --tg-csa-top: 0px;
  --tg-csa-right: 0px;
  --tg-csa-left: 0px;
  --app-chrome-h: 68px;
  --app-header-bg: #0e0f13;
  --app-hint: #8b90a3;
  --app-border: #2a2e3f;
  --app-surface: #171922;
}

/* Telegram-шапка: [AE] ArtEast_Core_Bot + подпись (mobile / fullscreen) */
.tg-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 11000;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--app-chrome-h);
  padding-top: var(--tg-sa-top);
  padding-bottom: 6px;
  padding-left: max(14px, calc(var(--tg-sa-left) + var(--tg-csa-left) + 14px));
  padding-right: max(72px, calc(var(--tg-sa-right) + var(--tg-csa-right) + 72px));
  box-sizing: border-box;
  background: var(--app-header-bg);
  pointer-events: none;
}

.tg-topbar-logo,
.head-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6c5ce7, #00d2ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11px;
  color: #fff;
  flex: 0 0 auto;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.tg-topbar-titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tg-topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: #eef1f7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.tg-topbar-sub {
  font-size: 11px;
  color: var(--app-hint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

/* Desktop в окне: нативная шапка Telegram, наш topbar скрыт, видна строка ← ⛶ */
body.miniapp.tg-win-logo .tg-topbar {
  display: none !important;
}

body.miniapp.tg-win-logo.has-tg-topbar {
  padding-top: 0;
}

body.miniapp.tg-win-logo .head,
body.miniapp.tg-win-logo .editor-header {
  display: flex;
  position: relative;
  z-index: 200;
  background: var(--app-header-bg);
}

body.miniapp.has-tg-topbar:not(.tg-win-logo) {
  padding-top: calc(var(--app-chrome-h) + var(--tg-sa-top) + 6px);
}

body.miniapp.tg-fs-header.has-tg-topbar {
  padding-top: calc(var(--app-chrome-h) + var(--tg-sa-top) + 6px);
}

/* Строка страницы не уходит под fixed topbar */
body.miniapp.has-tg-topbar:not(.tg-win-logo) .head,
body.miniapp.has-tg-topbar:not(.tg-win-logo) .editor-header,
body.miniapp.tg-fs-header .head,
body.miniapp.tg-fs-header .editor-header {
  position: relative;
  z-index: 200;
  background: var(--app-header-bg);
}

/* Строка страницы: ←  заголовок  ⛶ */
.app-head,
.head,
.editor-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 8px;
  position: relative;
  z-index: 200;
  flex-shrink: 0;
}
.app-head-titles,
.head > div:not(.back):not(.btn-back):not(.win-max):not(.head-logo),
.editor-header > div:not(.btn-back):not(.win-max):not(.head-logo):not([style*="display:none"]) {
  flex: 1;
  min-width: 0;
}

.app-head h1,
.head h1,
.editor-header h1 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  line-height: 1.25;
}

.app-head .sub,
.head .sub,
.editor-header .sub {
  font-size: 12px;
  color: var(--app-hint);
  margin-top: 2px;
  line-height: 1.3;
}

.app-back,
.back,
.btn-back {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  cursor: pointer;
  padding: 0;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  color: #eef1f7;
  font-size: 18px;
  line-height: 1;
}

.app-back:active,
body.miniapp .back:active,
body.miniapp .btn-back:active {
  background: #222637;
}

/* ⛶ 📌 — в строке head, не fixed (не уезжает на ПК) */
body.miniapp .head .win-max,
body.miniapp .editor-header .win-max,
body.miniapp .win-max,
body.miniapp .head .win-pin,
body.miniapp .editor-header .win-pin,
body.miniapp .win-pin {
  flex: 0 0 auto;
  position: static;
  top: auto;
  right: auto;
  width: 34px;
  height: 34px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  cursor: pointer;
  padding: 0;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  color: #eef1f7;
  font-size: 16px;
  line-height: 1;
  z-index: auto;
}

body.miniapp .head .win-pin,
body.miniapp .editor-header .win-pin,
body.miniapp .win-pin {
  font-size: 15px;
}

body.miniapp .head .win-max.show,
body.miniapp .editor-header .win-max.show,
body.miniapp .win-max.show,
body.miniapp .head .win-pin.show,
body.miniapp .editor-header .win-pin.show,
body.miniapp .win-pin.show {
  display: flex;
}

body.miniapp .win-max:active,
body.miniapp .win-pin:active {
  background: #222637;
}

body.miniapp .win-pin.active {
  border-color: #6c5ce7;
  background: #2a2540;
  box-shadow: 0 0 0 1px rgba(108, 92, 231, 0.35);
}

body.miniapp {
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
}

@media (min-width: 600px) {
  body.miniapp {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }

  .app-head,
  .head,
  .editor-header {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (min-width: 960px) {
  body.miniapp {
    max-width: 800px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  body.miniapp {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(120%);
  z-index: 20000;
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(28, 30, 40, 0.94);
  color: #eef1f7;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
  opacity: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.app-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@media (pointer: coarse) {
  .miniapp-touch,
  .asset-dl,
  .asset-fs,
  .asset-chip,
  .kb-btn,
  .tgph-toggle {
    min-height: 44px;
  }
}
