:root {
  --tz-pwa-bg: var(--tz-bg, #f4fff4);
  --tz-pwa-surface: var(--tz-surface, #ffffff);
  --tz-pwa-surface-2: var(--tz-surface-2, #f7fcf8);
  --tz-pwa-border: var(--tz-border, #d7f0d7);
  --tz-pwa-text: var(--tz-text, #123019);
  --tz-pwa-muted: var(--tz-muted, #476b50);
  --tz-pwa-primary: var(--tz-primary, #2e9b4a);
  --tz-pwa-primary-2: var(--tz-primary-2, #2a8d43);
  --tz-pwa-shadow: var(--tz-shadow-strong, 0 24px 60px rgba(18, 48, 25, 0.14));
}

@media (prefers-color-scheme: dark) {
  :root {
    --tz-pwa-bg: #08110e;
    --tz-pwa-surface: #101a17;
    --tz-pwa-surface-2: #14211d;
    --tz-pwa-border: #223730;
    --tz-pwa-text: #e9f6ef;
    --tz-pwa-muted: #9bb9aa;
    --tz-pwa-primary: #56c487;
    --tz-pwa-primary-2: #7bd9b3;
    --tz-pwa-shadow: 0 28px 70px rgba(0, 0, 0, 0.42);
  }
}

body[data-theme='dark'] {
  --tz-pwa-bg: #08110e;
  --tz-pwa-surface: #101a17;
  --tz-pwa-surface-2: #14211d;
  --tz-pwa-border: #223730;
  --tz-pwa-text: #e9f6ef;
  --tz-pwa-muted: #9bb9aa;
  --tz-pwa-primary: #56c487;
  --tz-pwa-primary-2: #7bd9b3;
  --tz-pwa-shadow: 0 28px 70px rgba(0, 0, 0, 0.42);
}

.tz-pwa-install-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1400;
  display: grid;
  gap: 12px;
  width: min(360px, calc(100vw - 24px));
  pointer-events: none;
}

.tz-pwa-install-root[hidden] {
  display: none;
}

.tz-pwa-install-card {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--tz-pwa-border);
  border-radius: 22px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--tz-pwa-surface) 88%, white 12%) 0%, var(--tz-pwa-surface) 100%);
  box-shadow: var(--tz-pwa-shadow);
  color: var(--tz-pwa-text);
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  transition: opacity 180ms ease, transform 220ms ease, box-shadow 220ms ease;
}

.tz-pwa-install-root.is-visible .tz-pwa-install-card {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.tz-pwa-install-main {
  display: grid;
  gap: 10px;
}

.tz-pwa-install-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 7px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tz-pwa-primary) 14%, transparent);
  color: var(--tz-pwa-primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tz-pwa-install-kicker::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--tz-pwa-primary), var(--tz-pwa-primary-2));
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--tz-pwa-primary) 18%, transparent);
}

.tz-pwa-install-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
}

.tz-pwa-install-copy {
  margin: 0;
  color: var(--tz-pwa-muted);
  font-size: 0.93rem;
  line-height: 1.45;
}

.tz-pwa-install-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tz-pwa-install-button,
.tz-pwa-install-dismiss,
.tz-pwa-sheet-close,
.tz-pwa-sheet-action {
  appearance: none;
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease, color 160ms ease;
}

.tz-pwa-install-button,
.tz-pwa-sheet-action {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--tz-pwa-primary), var(--tz-pwa-primary-2));
  color: #fff;
  font-weight: 700;
  box-shadow: 0 12px 26px color-mix(in srgb, var(--tz-pwa-primary) 28%, transparent);
}

.tz-pwa-install-button:hover,
.tz-pwa-sheet-action:hover {
  transform: translateY(-1px);
}

.tz-pwa-install-dismiss {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tz-pwa-text) 8%, transparent);
  color: var(--tz-pwa-muted);
  font-size: 1.15rem;
  line-height: 1;
}

.tz-pwa-install-dismiss:hover,
.tz-pwa-sheet-close:hover {
  background: color-mix(in srgb, var(--tz-pwa-text) 12%, transparent);
  color: var(--tz-pwa-text);
}

.tz-pwa-install-dismiss:focus-visible,
.tz-pwa-install-button:focus-visible,
.tz-pwa-sheet-action:focus-visible,
.tz-pwa-sheet-close:focus-visible {
  outline: 2px solid var(--tz-pwa-primary);
  outline-offset: 3px;
}

.tz-pwa-sheet {
  pointer-events: auto;
  position: fixed;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(4, 12, 9, 0.34);
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.tz-pwa-sheet.is-open {
  opacity: 1;
  visibility: visible;
}

.tz-pwa-sheet-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 28px;
  border: 1px solid var(--tz-pwa-border);
  background: linear-gradient(180deg, var(--tz-pwa-surface-2) 0%, var(--tz-pwa-surface) 100%);
  box-shadow: var(--tz-pwa-shadow);
  color: var(--tz-pwa-text);
  transform: translateY(22px);
  transition: transform 220ms ease;
}

.tz-pwa-sheet.is-open .tz-pwa-sheet-card {
  transform: translateY(0);
}

.tz-pwa-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tz-pwa-sheet-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.tz-pwa-sheet-close {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tz-pwa-text) 8%, transparent);
  color: var(--tz-pwa-muted);
  font-size: 1.15rem;
}

.tz-pwa-sheet-copy,
.tz-pwa-sheet-steps {
  margin: 0;
  color: var(--tz-pwa-muted);
  line-height: 1.55;
}

.tz-pwa-sheet-steps {
  padding-left: 1.2rem;
}

.tz-pwa-sheet-note {
  padding: 12px 14px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--tz-pwa-primary) 10%, transparent);
  color: var(--tz-pwa-text);
  font-size: 0.92rem;
}

.tz-pwa-offline-page {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, color-mix(in srgb, var(--tz-pwa-primary) 18%, transparent), transparent 38%),
    linear-gradient(180deg, var(--tz-pwa-bg) 0%, color-mix(in srgb, var(--tz-pwa-bg) 88%, var(--tz-pwa-surface) 12%) 100%);
  color: var(--tz-pwa-text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.tz-pwa-offline-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.tz-pwa-offline-card {
  width: min(420px, 100%);
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 28px 24px;
  border: 1px solid var(--tz-pwa-border);
  border-radius: 28px;
  background: linear-gradient(180deg, var(--tz-pwa-surface-2) 0%, var(--tz-pwa-surface) 100%);
  box-shadow: var(--tz-pwa-shadow);
  text-align: center;
}

.tz-pwa-offline-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
}

.tz-pwa-offline-title {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.05;
}

.tz-pwa-offline-copy {
  margin: 0;
  color: var(--tz-pwa-muted);
  font-size: 1rem;
}

@supports not (background: color-mix(in srgb, white 50%, black 50%)) {
  .tz-pwa-install-card,
  .tz-pwa-sheet-card,
  .tz-pwa-offline-card {
    background: var(--tz-pwa-surface);
  }

  .tz-pwa-install-kicker {
    background: rgba(46, 155, 74, 0.12);
  }

  .tz-pwa-sheet-note {
    background: rgba(46, 155, 74, 0.08);
  }
}

@media (max-width: 640px) {
  .tz-pwa-install-root {
    right: 12px;
    left: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
  }

  .tz-pwa-install-card {
    border-radius: 20px;
  }

  .tz-pwa-sheet {
    padding: 12px;
  }

  .tz-pwa-sheet-card {
    border-radius: 24px;
  }
}
