:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #100c16);
  --surface: var(--tg-theme-secondary-bg-color, #1b1524);
  --text: var(--tg-theme-text-color, #fff8fb);
  --muted: var(--tg-theme-hint-color, #a99fac);
  --accent: var(--tg-theme-button-color, #ff3b6b);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--text) 11%, transparent);
  --danger: #ffb02e;
  --radius: 26px;
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 8%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 36%),
    linear-gradient(165deg, var(--bg), color-mix(in srgb, var(--bg) 84%, #2d1234));
  overflow-x: hidden;
}

button, input, select, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.ambient { position: fixed; width: 240px; height: 240px; border-radius: 50%; filter: blur(90px); opacity: .18; pointer-events: none; }
.ambient-one { background: #ff316b; right: -100px; top: 15%; }
.ambient-two { background: #7549ff; left: -120px; bottom: 5%; }

.app-shell { width: min(100%, 560px); margin: 0 auto; padding: 18px 18px calc(104px + var(--safe-bottom)); position: relative; z-index: 1; }
.topbar { display: flex; align-items: center; gap: 12px; min-height: 58px; margin-bottom: 28px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(145deg, #ff6b8f, var(--accent)); color: white; font-weight: 900; box-shadow: 0 10px 34px color-mix(in srgb, var(--accent) 38%, transparent); }
.brand-mark.large { width: 72px; height: 72px; border-radius: 24px; font-size: 30px; margin: 0 auto 18px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 21px; line-height: 1; margin: 4px 0 0; letter-spacing: -.03em; }
h1 span { color: var(--accent); }
h2 { font-size: clamp(28px, 8vw, 40px); line-height: 1; margin-bottom: 0; letter-spacing: -.055em; }
h3 { font-size: 22px; margin-bottom: 18px; }
.eyebrow { margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.icon-button { margin-left: auto; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 84%, transparent); font-size: 23px; }

.screen { display: none; animation: enter .24s ease-out; }
.screen.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.screen-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 20px; }
.mini-stat { display: grid; text-align: right; }
.mini-stat strong { font-size: 24px; }
.mini-stat span { color: var(--muted); font-size: 12px; }

.candidate-area { min-height: 480px; }
.profile-card, .skeleton-card {
  min-height: min(66vh, 590px);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0,0,0,.3);
}
.skeleton-card { background: linear-gradient(110deg, var(--surface) 20%, color-mix(in srgb, var(--surface) 80%, white) 45%, var(--surface) 70%); background-size: 220% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position-x: -220%; } }
.profile-photo { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; background: linear-gradient(155deg, #4c254c, #17111e); }
.photo-placeholder { position: absolute; inset: 0; display: grid; place-items: center; font-size: 94px; font-weight: 900; color: color-mix(in srgb, var(--text) 42%, transparent); background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 34%, #2b1834), var(--surface)); }
.profile-gradient { position: absolute; inset: 25% 0 0; background: linear-gradient(transparent, rgba(8,5,10,.93) 82%); }
.profile-copy { position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 24px; }
.profile-title { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.profile-title h3 { font-size: 34px; margin: 0; color: white; letter-spacing: -.04em; }
.verified { color: #57d7ff; font-size: 20px; }
.profile-meta { color: rgba(255,255,255,.82); margin: 0 0 13px; font-weight: 650; }
.profile-bio { color: rgba(255,255,255,.9); margin: 0; line-height: 1.45; white-space: pre-wrap; }
.swipe-actions { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: -29px; position: relative; z-index: 3; }
.round-action { width: 62px; height: 62px; border: 0; border-radius: 50%; font-size: 34px; font-weight: 700; box-shadow: 0 12px 38px rgba(0,0,0,.35); transition: transform .14s ease, filter .14s ease; }
.round-action:active { transform: scale(.9); }
.round-action.primary { width: 72px; height: 72px; color: white; background: linear-gradient(145deg, #ff6a8c, var(--accent)); }
.round-action.secondary { background: #25202b; color: #ece6ee; }
.round-action.danger { width: 48px; height: 48px; background: #30251b; color: var(--danger); font-size: 23px; }

.empty-card, .external-card, .error-card, .settings-card { padding: 28px; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 91%, transparent); box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.empty-card { min-height: 390px; display: grid; place-items: center; text-align: center; align-content: center; }
.empty-symbol { font-size: 58px; color: var(--accent); margin-bottom: 15px; }
.empty-card p, .external-card p, .error-card p { color: var(--muted); line-height: 1.5; }
.external-card, .error-card { text-align: center; margin-top: 18vh; }
.primary-link, .primary-button { display: inline-flex; justify-content: center; align-items: center; min-height: 50px; padding: 0 22px; border: 0; border-radius: 16px; color: var(--accent-text); background: var(--accent); text-decoration: none; font-weight: 800; }
.primary-button { width: 100%; }
.secondary-button { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 15px; background: transparent; }

.match-list { display: grid; gap: 12px; }
.match-row { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 13px; padding: 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); }
.match-avatar { width: 58px; height: 58px; border-radius: 18px; object-fit: cover; background: linear-gradient(145deg, var(--accent), #5b3cb7); display: grid; place-items: center; font-size: 23px; font-weight: 900; }
.match-row h3 { margin: 0 0 3px; font-size: 18px; }
.match-row p { margin: 0; color: var(--muted); font-size: 13px; }
.contact-link { padding: 9px 12px; border-radius: 12px; color: var(--accent-text); background: var(--accent); text-decoration: none; font-weight: 800; font-size: 13px; }

.my-profile { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: center; margin-bottom: 24px; }
.my-profile .match-avatar { width: 72px; height: 72px; border-radius: 22px; }
.my-profile h3 { margin: 0 0 5px; }
.my-profile p { margin: 0; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 26px; }
.stat { padding: 14px 8px; text-align: center; border: 1px solid var(--line); border-radius: 16px; }
.stat strong { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 11px; }
.field { display: grid; gap: 8px; margin-bottom: 15px; }
.field label, .toggle-row span { color: var(--muted); font-size: 13px; font-weight: 700; }
.range-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input, select { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; color: var(--text); background: color-mix(in srgb, var(--bg) 72%, var(--surface)); }
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0 20px; }
.switch { position: relative; width: 52px; height: 30px; }
.switch input { opacity: 0; position: absolute; }
.switch-track { position: absolute; inset: 0; border-radius: 20px; background: #4a424e; transition: .2s; }
.switch-track::after { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; border-radius: 50%; background: white; transition: .2s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(22px); }
.action-stack { display: grid; gap: 9px; margin-top: 16px; }

.bottom-nav { position: fixed; z-index: 10; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 560px); display: grid; grid-template-columns: repeat(3, 1fr); padding: 10px 18px var(--safe-bottom); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(22px); }
.nav-item { border: 0; background: transparent; color: var(--muted); display: grid; justify-items: center; gap: 2px; }
.nav-item span { font-size: 21px; }
.nav-item small { font-size: 10px; font-weight: 800; }
.nav-item.active { color: var(--accent); }
.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(92px + var(--safe-bottom)); transform: translate(-50%, 20px); width: min(calc(100% - 36px), 500px); padding: 13px 16px; border-radius: 14px; color: white; background: rgba(18,14,20,.94); text-align: center; opacity: 0; pointer-events: none; transition: .22s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

dialog { width: min(calc(100% - 32px), 480px); border: 0; padding: 0; border-radius: 24px; color: var(--text); background: var(--surface); }
dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(5px); }
.dialog-card { padding: 24px; }
.report-options { display: grid; gap: 8px; }
.report-options button { min-height: 46px; border: 1px solid var(--line); border-radius: 14px; background: transparent; text-align: left; padding: 0 14px; }
.text-button { width: 100%; margin-top: 12px; border: 0; background: transparent; color: var(--muted); min-height: 42px; }
[hidden] { display: none !important; }

@media (min-width: 620px) {
  .app-shell { padding-top: 28px; }
  .profile-card, .skeleton-card { min-height: 620px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
