:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #f6f7f9);
  --text: var(--tg-theme-text-color, #16181d);
  --muted: var(--tg-theme-hint-color, #667085);
  --panel: var(--tg-theme-secondary-bg-color, #ffffff);
  --button: var(--tg-theme-button-color, #1f6feb);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(120, 126, 140, 0.24);
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

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

.shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}

.status {
  padding: 8px 0 18px;
}

.caption {
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}

h1 {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 30px;
  letter-spacing: 0;
}

.muted {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}

.config,
.error {
  background: var(--panel);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.error {
  color: var(--danger);
  line-height: 22px;
}

.primary-action,
.secondary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 650;
  text-decoration: none;
}

.primary-action {
  border: 0;
  background: var(--button);
  color: var(--button-text);
}

.secondary-action {
  margin-top: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 18px 0 12px;
}

#qrImage {
  width: min(72vw, 260px);
  height: min(72vw, 260px);
  image-rendering: pixelated;
  border-radius: 8px;
}

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

.tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.tab.active {
  border-color: var(--button);
  background: color-mix(in srgb, var(--button) 12%, transparent);
}

.app-links {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.app-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
}

.app-link span:last-child {
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none;
}
