:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #0d0f14);
  --surface: var(--tg-theme-secondary-bg-color, #171a21);
  --surface-2: color-mix(in srgb, var(--surface) 82%, white 6%);
  --text: var(--tg-theme-text-color, #f5f7fb);
  --hint: var(--tg-theme-hint-color, #8b93a7);
  --link: var(--tg-theme-link-color, #69a7ff);
  --button: var(--tg-theme-button-color, #3f7cff);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --border: color-mix(in srgb, var(--hint) 25%, transparent);
  --success: #31c36b;
  --warning: #e2aa3a;
  --danger: #e05555;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  padding:
    max(18px, env(safe-area-inset-top))
    16px
    max(30px, env(safe-area-inset-bottom));
}

button {
  font: inherit;
}

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow,
.hero-kicker {
  margin: 0 0 5px;
  color: var(--hint);
  font-size: 12px;
  letter-spacing: 0.14em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 25px;
}

.user-badge {
  max-width: 45%;
  overflow: hidden;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--hint);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background:
    radial-gradient(
      circle at 90% 10%,
      color-mix(in srgb, var(--button) 22%, transparent),
      transparent 45%
    ),
    var(--surface);
}

.hero h2 {
  margin-bottom: 8px;
  font-size: 26px;
}

.hero p:last-child {
  max-width: 520px;
  margin-bottom: 0;
  color: var(--hint);
  line-height: 1.5;
}

.hero-icon {
  display: grid;
  flex: 0 0 74px;
  width: 74px;
  height: 74px;
  place-items: center;
  border-radius: 22px;
  background: color-mix(in srgb, var(--button) 18%, transparent);
  color: var(--button);
  font-size: 34px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 5px;
  margin-bottom: 18px;
  border-radius: 15px;
  background: var(--surface);
}

.tab {
  padding: 10px 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--hint);
  cursor: pointer;
}

.tab.active {
  background: var(--button);
  color: var(--button-text);
}

.status {
  display: none;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  line-height: 1.4;
}

.status.visible {
  display: block;
}

.status.error {
  border-color: color-mix(in srgb, var(--danger) 60%, var(--border));
}

.status.success {
  border-color: color-mix(in srgb, var(--success) 60%, var(--border));
}

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

.product-card {
  display: flex;
  min-height: 220px;
  flex-direction: column;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  cursor: pointer;
}

.product-card:active {
  transform: scale(0.99);
}

.file-icon {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 16px;
  background: color-mix(in srgb, var(--button) 17%, transparent);
  color: var(--button);
  font-size: 12px;
  font-weight: 700;
}

.product-title {
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 700;
}

.product-description {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 16px;
  color: var(--hint);
  font-size: 14px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.price {
  font-size: 20px;
  font-weight: 800;
}

.formats {
  color: var(--hint);
  font-size: 12px;
  text-align: right;
}

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

.order-card {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.order-top,
.order-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.order-bottom {
  margin-top: 10px;
  color: var(--hint);
  font-size: 13px;
}

.order-status {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--hint);
  font-size: 12px;
}

.order-status.delivered {
  color: var(--success);
}

.order-status.paid,
.order-status.delivering {
  color: var(--warning);
}

.product-dialog {
  width: min(520px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
}

.product-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.dialog-content {
  position: relative;
  padding: 24px;
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
}

.dialog-icon {
  display: grid;
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
  place-items: center;
  border-radius: 18px;
  background: color-mix(in srgb, var(--button) 17%, transparent);
  color: var(--button);
  font-size: 12px;
  font-weight: 800;
}

.dialog-description {
  color: var(--hint);
  line-height: 1.55;
}

.product-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 20px 0;
}

.product-meta span {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--hint);
  font-size: 13px;
}

.checkout-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}

.checkout-row strong {
  font-size: 25px;
}

.primary-button {
  min-width: 140px;
  padding: 13px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--button);
  color: var(--button-text);
  font-weight: 700;
  cursor: pointer;
}

.primary-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.hidden {
  display: none !important;
}

.empty-state {
  padding: 28px 18px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  color: var(--hint);
  text-align: center;
}

@media (max-width: 520px) {
  .product-grid {
    grid-template-columns: 1fr;
  }

  .hero-icon {
    display: none;
  }
}
