/* Steamify v2 — app pages: sessions, results, mentor and admin panels, sign-in.
   Builds on the site.css tokens. The .cp-* and .admin-* markup is rendered by /community.js and /admin.js. */

/* ---------- Compact hero with section tabs ---------- */

.app-hero { padding: calc(var(--header-h) + 44px) 0 0; border-bottom: 0; box-shadow: inset 0 -1px 0 var(--line); }
.app-hero .breadcrumbs { margin-bottom: 18px; }
.app-hero h1 { font-size: clamp(34px, 4.6vw, 56px); margin-top: 14px; }
.app-hero p { font-size: 17px; margin-top: 14px; }

.cp-nav { display: flex; gap: 4px; margin-top: 30px; overflow-x: auto; scrollbar-width: none; }
.cp-nav::-webkit-scrollbar { display: none; }
.cp-nav a {
  flex: none; padding: 12px 16px 13px; border-bottom: 2px solid transparent;
  color: var(--text-2); font-size: 15px; font-weight: 600; white-space: nowrap;
  transition: color .2s, border-color .2s;
}
.cp-nav a:hover { color: var(--text); }
.cp-nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.cp-nav a:focus-visible { outline-offset: -3px; }

.app-section { padding-block: 40px 96px; }
.app-content { display: grid; gap: 24px; }
.app-content > *, #community-content > * { min-width: 0; }
#community-content { display: grid; gap: 24px; }
.app-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-top: 16px; }
.app-head h2 { font-size: clamp(26px, 3vw, 34px); }

/* Placeholder until community.js renders; hidden if loading fails with an error notice. */
.app-skeleton { display: grid; gap: 16px; }
.app-skeleton .skeleton { height: 140px; border-radius: var(--radius-lg); }
.app-skeleton.grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.app-skeleton.grid .skeleton { height: 340px; }
#notice.cp-error:not([hidden]) + #community-content > .app-skeleton { display: none; }

/* ---------- Cards, notes, text ---------- */

.cp-card {
  --pad: clamp(20px, 3vw, 30px);
  min-width: 0; padding: var(--pad);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.app-content :where(.cp-card, form, #staff-tools) > * + * { margin-top: 16px; }
.cp-card h2 { font-size: 22px; letter-spacing: -.02em; }
.cp-card h3 { font-size: 19px; line-height: 1.25; letter-spacing: -.015em; }
.cp-card .cp-card { background: var(--surface-2); box-shadow: none; }
.cp-card > a:not(.cp-button) { display: inline-flex; width: fit-content; color: var(--accent); font-weight: 650; font-size: 15px; }
.cp-card > a:not(.cp-button):hover { text-decoration: underline; text-underline-offset: 3px; }

.app-content .muted { color: var(--text-2); font-size: 17px; max-width: 720px; }
.app-content small { display: block; color: var(--text-3); font-size: 13px; line-height: 1.5; }
.cp-meta { color: var(--text-2); font-size: 14px; line-height: 1.6; }

.cp-note {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px 18px; border-radius: 14px;
  background: var(--surface-2); border: 1px dashed var(--line-strong);
  color: var(--text-2); font-size: 15px;
}
.cp-note::before {
  content: ""; flex: none; width: 20px; height: 20px; margin-top: 1px; background: var(--accent);
  -webkit-mask: var(--note-icon) center / contain no-repeat; mask: var(--note-icon) center / contain no-repeat;
  --note-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 7.8h.01'/%3E%3C/svg%3E");
}
#notice { border-style: solid; background: color-mix(in srgb, var(--success) 10%, var(--surface)); border-color: color-mix(in srgb, var(--success) 35%, transparent); color: var(--text); font-weight: 550; }
#notice::before { background: var(--success); --note-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
#notice.cp-error { background: color-mix(in srgb, var(--danger) 9%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
#notice.cp-error::before { background: var(--danger); --note-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5.5M12 16.2h.01'/%3E%3C/svg%3E"); }

.cp-status {
  display: inline-flex; align-items: center; gap: 8px; width: fit-content;
  padding: 5px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.cp-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Buttons ---------- */

.app-content :where(button, .cp-button) {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: fit-content; min-height: 44px; padding: 0 20px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 650; line-height: 1.2; text-align: center; white-space: nowrap;
  transition: transform .2s var(--ease), box-shadow .25s var(--ease), background-color .2s, border-color .2s, color .2s;
}
.app-content :where(button, .cp-button):hover { border-color: var(--accent-line); color: var(--accent); }
.app-content :where(button, .cp-button):active { transform: translateY(1px); }
.app-content :where(button.primary, form > button:not([type="button"]), #camera-start, #community-content > .cp-note + .cp-button) {
  border-color: transparent; background: var(--accent); color: #fff; box-shadow: var(--glow);
}
.app-content :where(button.primary, form > button:not([type="button"]), #camera-start, #community-content > .cp-note + .cp-button):hover {
  border-color: transparent; background: color-mix(in srgb, var(--accent) 88%, #fff); color: #fff;
}
.app-content :where(#close-event, #revoke-form > button) { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: transparent; color: var(--danger); box-shadow: none; }
.app-content :where(#close-event, #revoke-form > button):hover { background: color-mix(in srgb, var(--danger) 9%, transparent); color: var(--danger); }
.app-content button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* Compact buttons inside tables */
.cp-table button { min-height: 36px; padding: 0 14px; font-size: 14px; }
.cp-table :is([data-check], [data-qr], [data-manage-event]) { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.cp-table :is([data-check], [data-qr], [data-manage-event]):hover { background: var(--accent); color: #fff; }

/* ---------- Forms ---------- */

.app-content label { display: grid; gap: 8px; font-size: 14px; font-weight: 650; color: var(--text); }
.app-content :where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="hidden"]), select, textarea) {
  display: block; width: 100%; height: 48px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 14px;
  background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 400;
  transition: border-color .2s, box-shadow .2s;
}
.app-content textarea { height: auto; min-height: 120px; padding: 12px 16px; line-height: 1.55; resize: vertical; }
.app-content select {
  appearance: none; padding-right: 44px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a87a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 18px;
}
.app-content :is(input, select, textarea):focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.app-content :is(input, textarea)::placeholder { color: var(--text-3); }
.app-content :is(input, select):disabled { background-color: var(--surface-2); color: var(--text-2); cursor: not-allowed; }
.app-content input[readonly] { background-color: var(--surface-2); }
.app-content input[type="file"] {
  width: 100%; padding: 10px; border: 1px dashed var(--line-strong); border-radius: 14px;
  background: var(--surface-2); color: var(--text-2); font-size: 14px; font-weight: 400;
}
.app-content input[type="file"]::file-selector-button {
  height: 36px; margin-right: 12px; padding: 0 16px; border: 0; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font: inherit; font-weight: 650; cursor: pointer;
}
.cp-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 16px; }
.cp-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Referral link: field and copy button on one row */
.cp-card:has(#ref-link) { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: end; }
.cp-card:has(#ref-link) > :not(label, #copy-ref) { grid-column: 1 / -1; }
.app-content :is(#copy-ref, #revoke-form > button) { min-height: 48px; }

.app-content video { width: 100%; max-height: 380px; border-radius: 18px; background: #050b1c; object-fit: cover; }

/* ---------- Tables ---------- */

.cp-table { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.cp-table table { width: 100%; border-collapse: collapse; text-align: left; font-size: 15px; }
.cp-table th {
  padding: 12px 16px; background: var(--surface-2); color: var(--text-3);
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
}
.cp-table td { padding: 14px 16px; border-top: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.cp-table tbody tr { transition: background-color .2s; }
.cp-table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.cp-table td small { margin-top: 2px; }
.cp-table td strong { font-family: var(--font-display); font-weight: 800; }
.cp-table select { height: 38px; min-width: 140px; border-radius: 12px; }

/* ---------- Session cards ---------- */

.cp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 20px; }
.cp-grid > .cp-card {
  display: flex; flex-direction: column; gap: 12px; overflow: hidden;
  transition: transform .35s var(--ease), border-color .3s, box-shadow .35s var(--ease);
}
.cp-grid > .cp-card:hover { transform: translateY(-4px); border-color: var(--accent-line); box-shadow: var(--shadow); }
.cp-grid > .cp-card > * + * { margin-top: 0; }
.cp-grid > .cp-card img.cover {
  width: calc(100% + 2 * var(--pad)); max-width: none; aspect-ratio: 16 / 9; object-fit: cover;
  margin: calc(-1 * var(--pad)) calc(-1 * var(--pad)) 6px; background: #050b1c;
}
.cp-grid > .cp-card p:not(.cp-meta) { color: var(--text-2); font-size: 15px; }
.cp-grid > .cp-card .cp-meta { padding-top: 12px; border-top: 1px solid var(--line); }
.cp-grid > .cp-card > :is(button, .cp-button) { width: 100%; margin-top: auto; }
.cp-grid > .cp-card > small + :is(button, .cp-button) { margin-top: 8px; }

/* ---------- Results ---------- */

.cp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cp-stats .cp-card { display: grid; align-content: start; gap: 14px; }
.cp-stats .cp-card > * + * { margin-top: 0; }
.cp-stats span { color: var(--text-2); font-size: 14px; font-weight: 600; }
.cp-stats strong { font-family: var(--font-display); font-size: clamp(32px, 4vw, 46px); font-weight: 800; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.cp-stats .cp-card:first-child {
  position: relative; overflow: hidden; isolation: isolate; border-color: transparent; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #1b4fd8 0%, var(--navy) 50%, var(--navy-deep) 100%);
}
.cp-stats .cp-card:first-child span { color: rgba(255, 255, 255, .75); }

/* ---------- QR dialog ---------- */

.cp-qr { width: min(400px, calc(100% - 32px)); text-align: center; }
.cp-qr .modal-body { justify-items: center; }
.cp-qr .modal-body h2 { padding-right: 0; }
.cp-qr img { width: 240px; aspect-ratio: 1; padding: 12px; border-radius: 18px; background: #fff; border: 1px solid var(--line); }
.cp-qr .btn { width: 100%; }

/* ---------- Featured event (sessions page) ---------- */

.app-feature .event-feature-body h2 { font-size: clamp(26px, 3vw, 36px); }

/* ---------- Admin panel ---------- */

#admin-overview { display: grid; gap: 20px; }
.admin-welcome {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: clamp(24px, 4vw, 44px); border-radius: var(--radius-lg); color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #1b4fd8 0%, var(--navy) 45%, var(--navy-deep) 100%);
}
.admin-welcome::before, .cp-stats .cp-card:first-child::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: linear-gradient(110deg, transparent 30%, #000 100%); mask-image: linear-gradient(110deg, transparent 30%, #000 100%);
}
.admin-welcome span { display: inline-flex; align-items: center; gap: 10px; color: #8fc0ff; font-size: 13px; font-weight: 700; letter-spacing: .14em; }
.admin-welcome span::before { content: ""; width: 22px; height: 2px; border-radius: 2px; background: currentColor; }
.admin-welcome h2 { font-size: clamp(26px, 3.4vw, 38px); margin: 14px 0 10px; }
.admin-welcome p { color: rgba(255, 255, 255, .75); font-size: 16px; }
.app-content .admin-welcome button { flex: none; border-color: transparent; background: #fff; color: var(--navy); }
.app-content .admin-welcome button:hover { color: var(--navy); box-shadow: 0 16px 40px -16px rgba(255, 255, 255, .6); }
.admin-shortcuts { display: flex; flex-wrap: wrap; gap: 10px; }
.admin-shortcuts a {
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text-2); font-size: 14px; font-weight: 600; transition: border-color .2s, color .2s;
}
.admin-shortcuts a:hover { border-color: var(--accent-line); color: var(--accent); }
.admin-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.admin-metrics article { padding: 22px 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.admin-metrics span { color: var(--text-2); font-size: 14px; font-weight: 600; }
.admin-metrics strong { display: block; margin-top: 10px; font-family: var(--font-display); font-size: clamp(30px, 3.4vw, 40px); font-weight: 800; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.admin-insights { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.cp-card > .admin-region { margin-top: 0; }
.admin-region { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.admin-region:last-child { border-bottom: 0; padding-bottom: 0; }
.admin-region strong { font-family: var(--font-display); font-weight: 800; color: var(--accent); }
.admin-region > small { flex: none; }
.admin-user-filters { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.admin-user-filters p { grid-column: 1 / -1; color: var(--text-3); font-size: 14px; }
#admin-management > h2:not(:first-child) { margin-top: 36px; padding-top: 28px; border-top: 1px solid var(--line); }
#admin-management > p { color: var(--text-2); }
#revoke-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
#revoke-form > * + * { margin-top: 0; }

/* ---------- Sign-in page ---------- */

.auth-main { position: relative; overflow: hidden; margin-top: calc(-1 * var(--header-h)); padding: calc(var(--header-h) + 48px) 0 88px; }
.auth-main .bg-glow { width: 560px; height: 560px; top: -260px; right: -120px; }
.auth-layout {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  max-width: 1040px; margin-inline: auto; overflow: hidden;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.auth-art {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 24px;
  padding: clamp(28px, 4vw, 48px); color: #fff;
  background: radial-gradient(120% 120% at 100% 0%, #1b4fd8 0%, var(--navy) 48%, var(--navy-deep) 100%);
}
.auth-art::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 20%, transparent 80%); mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 20%, transparent 80%);
}
.auth-art .eyebrow { color: #8fc0ff; }
.auth-art h1 { font-size: clamp(28px, 3vw, 38px); letter-spacing: -.03em; }
.auth-art h1 .grad-text { background-image: linear-gradient(100deg, #8fc0ff 0%, #fff 45%, #8fc0ff 90%); }
.auth-art p { margin-top: 14px; color: rgba(255, 255, 255, .75); font-size: 16px; max-width: 380px; }
.auth-perks { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 0; padding: 0; list-style: none; }
.auth-perks li {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14);
  font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, .9);
}
.auth-perks .icon { width: 16px; height: 16px; color: #8fc0ff; }

.auth-card { display: flex; flex-direction: column; justify-content: center; gap: 0; padding: clamp(28px, 5vw, 56px); background: var(--surface); }
.auth-card h2 { margin-top: 14px; font-size: clamp(30px, 3.4vw, 40px); letter-spacing: -.035em; }
.auth-subtitle { margin-top: 10px; color: var(--text-2); font-size: 16px; }
.auth-card form { display: grid; gap: 14px; margin-top: 28px; }
.auth-input { position: relative; }
.auth-input > .icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.auth-input .input { padding-left: 48px; }
.auth-input .input:has(+ .password-toggle) { padding-right: 52px; }
.auth-input:focus-within > .icon { color: var(--accent); }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-3); transition: color .2s, background-color .2s;
}
.password-toggle:hover, .password-toggle[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.password-toggle .icon { width: 20px; height: 20px; }
.auth-hint:empty, #verify-status:empty { display: none; }
.auth-hint, #verify-status { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 14px; line-height: 1.5; }
.auth-card .btn { width: 100%; }
#verify-email-label { padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-weight: 650; text-align: center; overflow-wrap: anywhere; }
#email-otp { height: 60px; padding: 0 16px; text-align: center; font-size: 24px; font-weight: 650; letter-spacing: .3em; font-variant-numeric: tabular-nums; }
.auth-divider { display: flex; align-items: center; gap: 14px; margin: 24px 0 16px; color: var(--text-3); font-size: 13px; font-weight: 600; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.social-login-button img { width: 20px; height: 20px; }
.auth-switch { margin-top: 18px; color: var(--text-2); font-size: 15px; text-align: center; }
.auth-switch + .auth-switch { margin-top: 8px; }
.auth-card form .auth-switch { margin-top: 0; }
.auth-link { padding: 0; border: 0; background: none; color: var(--accent); font-weight: 650; }
.auth-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.auth-link:disabled { color: var(--text-3); text-decoration: none; cursor: default; }
.auth-back { color: var(--text-3); font-weight: 600; }

/* The robot reacts to the pointer and closes its eyes while the password is focused (admin-login.js). */
.robot-scene { position: relative; display: flex; flex-direction: column; align-items: center; margin: 8px 0; }
.robot-float { width: min(240px, 70%); animation: robot-hover 4s ease-in-out infinite; }
.login-robot { width: 100%; filter: drop-shadow(0 16px 30px rgba(0, 0, 0, .35)); }
.robot-shadow { width: 110px; height: 12px; margin-top: 10px; border-radius: 50%; background: rgba(110, 165, 255, .3); filter: blur(9px); animation: robot-shadow 4s ease-in-out infinite; }
.robot-gaze { transform: translate(var(--look-x, 0px), var(--look-y, 0px)); transition: transform .14s ease-out; }
.robot-eyes { transform-origin: 130px 127px; animation: robot-blink 5s infinite; }
.robot-scene.is-private .robot-eyes { animation: none; transform: scaleY(.09); }
.robot-scene.is-private .robot-gaze { transform: translate(0, 3px); }
.robot-scene.is-private .robot-smile { opacity: .4; }
.robot-beacon { animation: robot-glow 2s ease-in-out infinite; }
@keyframes robot-hover { 50% { transform: translateY(-14px) rotate(-3deg); } }
@keyframes robot-shadow { 50% { transform: scaleX(.7); opacity: .5; } }
@keyframes robot-blink { 0%, 43%, 49%, 100% { transform: scaleY(1); } 46% { transform: scaleY(.08); } }
@keyframes robot-glow { 50% { opacity: .5; } }

/* ---------- Profile page (index.html, driven by /app.js) ---------- */

.profile-content, #account-view:not([hidden]) { display: grid; gap: 24px; }
#account-view > *, .profile-grid > *, .profile-panels > * { min-width: 0; }

.profile-head { overflow: hidden; border-radius: var(--radius-lg); }
.profile-cover, .referral-promo {
  position: relative; isolation: isolate;
  background: radial-gradient(120% 160% at 100% 0%, #1b4fd8 0%, var(--navy) 48%, var(--navy-deep) 100%);
}
.profile-cover { height: 128px; }
.profile-cover::before, .referral-promo::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: linear-gradient(110deg, transparent 25%, #000 100%); mask-image: linear-gradient(110deg, transparent 25%, #000 100%);
}
.profile-summary { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; padding: 0 clamp(20px, 3vw, 32px) clamp(20px, 3vw, 28px); }
.profile-identity { display: flex; align-items: flex-end; gap: 20px; min-width: 0; }
.profile-identity > div { min-width: 0; padding-bottom: 4px; }
.profile-avatar { --size: 104px; position: relative; margin-top: -52px; box-shadow: 0 0 0 6px var(--surface), 0 18px 36px -14px rgba(29, 95, 245, .7); }
.profile-identity h2 { font-size: clamp(24px, 3vw, 32px); letter-spacing: -.03em; overflow-wrap: anywhere; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 6px; color: var(--text-2); font-size: 15px; }
.profile-meta > span[aria-hidden] { color: var(--text-3); }
.profile-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.logout-btn:hover { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }

.profile-tabs { justify-self: start; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.profile-tabs .count { font-size: 11px; font-weight: 700; letter-spacing: .06em; }

.profile-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.profile-panel { display: grid; gap: 22px; padding: clamp(22px, 3vw, 32px); border-radius: var(--radius-lg); }
.panel-head { display: flex; align-items: flex-start; gap: 16px; }
.panel-ic { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 16px; background: var(--accent-soft); color: var(--accent); }
.panel-ic .icon { width: 22px; height: 22px; }
.panel-head h3 { font-size: 21px; }
.panel-head p { margin-top: 6px; color: var(--text-2); font-size: 15px; }

#profile-form { display: grid; gap: 22px; }
.profile-panel .field > label { font-size: 14px; font-weight: 650; }
.profile-panel .field > label span { color: var(--danger); }
.profile-panel .field small { color: var(--text-3); font-size: 13px; }
.profile-panel .field small.error { color: var(--danger); }
.profile-panel .field small.error:empty { display: none; }
.profile-panel [aria-invalid="true"] { border-color: var(--danger); }
.profile-panel [aria-invalid="true"]:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 14%, transparent); }
.form-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding-top: 20px; border-top: 1px solid var(--line); }
#save-state { color: var(--text-3); font-size: 14px; }

.connection-list { display: grid; gap: 12px; }
.connection-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px;
  padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2);
}
.provider { display: flex; align-items: center; gap: 14px; min-width: 0; }
.provider-logo { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.provider strong { display: block; font-size: 16px; }
.provider small { display: block; color: var(--text-3); font-size: 13px; overflow-wrap: anywhere; }
#google-connect, #telegram-connect { max-width: 100%; }
.connected-pill { display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); font-size: 13px; font-weight: 700; }
.unavailable { color: var(--text-3); font-size: 13px; }

.ref-stats { display: flex; align-items: center; gap: 20px; padding: 20px 22px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.ref-stats > strong { font-family: var(--font-display); font-size: 56px; font-weight: 800; line-height: 1; letter-spacing: -.04em; color: var(--accent); font-variant-numeric: tabular-nums; }
.ref-stats b { display: block; font-size: 17px; }
.ref-stats small { display: block; color: var(--text-2); font-size: 14px; }
.ref-stats .auth-link { margin-top: 8px; font-size: 14px; }
.referral-code-line { color: var(--text-2); font-size: 15px; }
.referral-code-line code, #new-recovery-code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--text); }
.referral-code-line code { padding: 3px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.copy-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.copy-field .input { background: var(--surface-2); text-overflow: ellipsis; }
#share-telegram { width: fit-content; }

.profile-aside { display: grid; gap: 20px; position: sticky; top: calc(var(--header-h) + 20px); }
.completion-card { display: grid; gap: 14px; padding: 24px; border-radius: var(--radius-lg); }
.small-title { color: var(--text-3); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.completion-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.completion-heading strong { font-family: var(--font-display); font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.completion-heading span { color: var(--text-2); font-weight: 600; }
.progress-track { height: 10px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
#progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #5fb4ff); transition: width .6s var(--ease); }
.completion-card > p { color: var(--text-2); font-size: 14px; }
#checklist { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
#checklist li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 14px; }
#checklist li span { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--line-strong); color: transparent; font-size: 12px; font-weight: 800; }
#checklist li.complete { color: var(--text); }
#checklist li.complete span { border-color: var(--success); background: var(--success); color: #fff; }

.referral-promo { overflow: hidden; display: grid; gap: 14px; padding: 26px; border-radius: var(--radius-lg); color: #fff; }
.referral-promo .eyebrow { color: #8fc0ff; }
.referral-promo h3 { font-size: 24px; }
.referral-promo p { color: rgba(255, 255, 255, .75); font-size: 14px; }
#quick-referral-link { width: 100%; height: 44px; padding: 0 14px; border: 1px solid rgba(255, 255, 255, .18); border-radius: 12px; background: rgba(255, 255, 255, .08); color: #fff; font-size: 14px; text-overflow: ellipsis; }
#quick-referral-link:focus { outline: none; border-color: #8fc0ff; }
.referral-promo .btn { width: 100%; }
.referral-promo .btn-outline-light { background: transparent; }

.app-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 32px); padding: 14px 18px; border-radius: 16px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 550; box-shadow: var(--shadow-lg);
  animation: toast-in .3s var(--ease);
}
.app-toast.failure { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

#policy-content { color: var(--text-2); line-height: 1.7; }
#new-recovery-code { display: block; padding: 16px; border-radius: 14px; border: 1px dashed var(--accent-line); background: var(--surface-2); font-size: 20px; font-weight: 700; letter-spacing: .08em; text-align: center; overflow-wrap: anywhere; }
.modal-actions .btn { flex: 1 1 auto; }

@media (max-width: 1100px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-aside { position: static; grid-template-columns: 1fr 1fr; align-items: start; }
}

@media (max-width: 640px) {
  .profile-content, #account-view:not([hidden]) { gap: 18px; }
  .profile-cover { height: 96px; }
  .profile-summary { flex-direction: column; align-items: stretch; }
  .profile-identity { flex-direction: column; align-items: flex-start; gap: 12px; }
  .profile-avatar { --size: 84px; margin-top: -42px; }
  .profile-actions .btn { flex: 1 1 auto; }
  .profile-tabs { justify-self: stretch; }
  .profile-aside { grid-template-columns: 1fr; }
  .panel-head { gap: 12px; }
  .panel-ic { width: 42px; height: 42px; border-radius: 14px; }
  .ref-stats { gap: 16px; padding: 16px 18px; }
  .ref-stats > strong { font-size: 44px; }
  .copy-field { grid-template-columns: 1fr; }
  #share-telegram, .form-footer .btn { width: 100%; }
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .admin-insights { grid-template-columns: 1fr; }
  .admin-welcome { flex-direction: column; align-items: flex-start; }
  .auth-layout { grid-template-columns: 1fr; max-width: 560px; }
  .auth-art { display: none; }
}

@media (max-width: 640px) {
  .app-hero { padding-top: calc(var(--header-h) + 28px); }
  .app-hero p { font-size: 16px; }
  .cp-nav { margin-top: 22px; margin-inline: calc(-1 * var(--gutter)); padding-inline: calc(var(--gutter) - 8px); }
  .cp-nav a { padding-inline: 12px; }
  .app-section { padding-block: 28px 72px; }
  .app-content, #community-content { gap: 18px; }
  .cp-card { border-radius: var(--radius); }
  .cp-stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .cp-stats .cp-card { padding: 18px; gap: 10px; }
  .cp-stats .cp-card:first-child { grid-column: 1 / -1; }
  .cp-stats span { font-size: 13px; }
  .admin-metrics { grid-template-columns: 1fr 1fr; gap: 12px; }
  .admin-metrics article { padding: 16px; }
  .admin-user-filters, #revoke-form { grid-template-columns: 1fr; }
  #revoke-form > * + * { margin-top: 0; }
  .app-content .admin-welcome button, #revoke-form > button { width: 100%; }
  .cp-card:has(#ref-link) { grid-template-columns: 1fr; row-gap: 12px; }
  .cp-card:has(#ref-link) > * + * { margin-top: 0; }
  .cp-card:has(#ref-link) #copy-ref { width: 100%; }
  .cp-actions button { flex: 1 1 auto; }
  .auth-main { padding: calc(var(--header-h) + 20px) 0 56px; }
  .auth-layout { box-shadow: var(--shadow); border: 1px solid var(--line); }
  .auth-card { padding: 28px 20px 32px; }
  .event-feature-body { gap: 16px; }
  .app-feature .event-feature-actions .btn { flex: 1 1 100%; height: auto; min-height: var(--btn-h); padding-block: 12px; white-space: normal; text-align: center; }
}

@media (max-width: 420px) {
  .cp-nav a { padding-inline: 8px; font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .robot-gaze { transition: none; }
}

/* First screen: sessions/profile header fills the viewport, title centred, section tabs at its bottom edge. */
.app-hero > .container { flex: 1; display: flex; flex-direction: column; }
.app-hero > .container > .breadcrumbs { margin-top: auto; }
.app-hero .cp-nav { margin-top: auto; padding-top: 30px; }
/* Sign-in: the card sits centred on the first screen; the footer starts below it. */
.auth-main { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; justify-content: center; }
