/* Profile overlay — zametki / zadachi neumorphism (aligned with app.css / home.scss) */
@import url("/static/fonts/comfortaa.css");

.b33-profile-overlay {
  /* Light neu — same as zametki.space / zadachi.space */
  --b33-ov-accent: #c24a36;
  --b33-ov-accent-wash: rgba(194, 74, 54, 0.12);
  --b33-ov-ink: #1e2330;
  --b33-ov-muted: #6b7280;
  --b33-ov-neu-bg: #f6eadf;
  --b33-ov-surface: #efe3d6;
  --b33-ov-neu:
    3px 3px 7px #ccc2b9,
    -3px -3px 7px #ffffff;
  --b33-ov-neu-sm:
    2px 2px 5px #ccc2b9,
    -2px -2px 5px #ffffff;
  --b33-ov-neu-lg:
    4px 4px 10px #ccc2b9,
    -3px -3px 8px #ffffff;
  --b33-ov-neu-in:
    inset 3px 3px 7px #ccc2b9,
    inset -3px -3px 7px #ffffff;
  --b33-ov-neu-press:
    inset 3px 3px 7px #ccc2b9,
    inset -2px -2px 5px #ffffff;
  --b33-ov-neu-accent:
    3px 3px 5px rgba(160, 50, 35, 0.35),
    -2px -2px 4px rgba(255, 200, 180, 0.45);
  --b33-ov-scrim: rgba(27, 30, 39, 0.55);
  --b33-ov-radius: 28px;
  --b33-ov-font: "Comfortaa", system-ui, sans-serif;
  --b33-ov-safe-b: env(safe-area-inset-bottom, 0px);
  --b33-ov-safe-t: env(safe-area-inset-top, 0px);
}

.b33-profile-overlay[data-brand="nya"] {
  --b33-ov-accent: #3d8b6e;
  --b33-ov-accent-wash: rgba(61, 139, 110, 0.14);
  --b33-ov-neu-accent:
    3px 3px 5px rgba(40, 100, 75, 0.3),
    -2px -2px 4px rgba(180, 230, 200, 0.45);
}

.b33-profile-overlay[data-brand="zam"] {
  /* Match brands.py / login .btn.primary — ink text as accent */
  --b33-ov-accent: #1E2330;
  --b33-ov-accent-wash: rgba(30, 35, 48, 0.12);
  --b33-ov-neu-accent:
    3px 3px 6px rgba(10, 10, 10, 0.22),
    -2px -2px 4px rgba(255, 255, 255, 0.55);
}

.b33-profile-overlay[data-brand="zad"] {
  --b33-ov-accent: #c24a36;
  --b33-ov-accent-wash: rgba(194, 74, 54, 0.12);
  --b33-ov-neu-accent:
    3px 3px 5px rgba(160, 50, 35, 0.35),
    -2px -2px 4px rgba(255, 200, 180, 0.45);
}

/* Dark theme — body.dark on zametki / zadachi */
body.dark .b33-profile-overlay,
.b33-profile-overlay[data-theme="dark"] {
  --b33-ov-ink: #e8e4dc;
  --b33-ov-muted: #9a948a;
  --b33-ov-neu-bg: #1b1e27;
  --b33-ov-surface: #242833;
  /* Soft dark neu — raised vs recessed stay distinct without #303644 halo */
  --b33-ov-neu:
    4px 4px 12px #0a0c10,
    -2px -2px 6px #2a2e38;
  --b33-ov-neu-sm:
    3px 3px 8px #0a0c10,
    -1px -1px 4px #2a2e38;
  --b33-ov-neu-lg:
    5px 5px 14px #0a0c10,
    -2px -2px 8px #2a2e38;
  --b33-ov-neu-in:
    inset 3px 3px 9px #0a0c10,
    inset -1px -1px 4px #2a2e38;
  --b33-ov-neu-press:
    inset 3px 3px 10px #0a0c10,
    inset -1px -1px 3px #2a2e38;
  --b33-ov-scrim: rgba(10, 12, 16, 0.72);
  color-scheme: dark;
}

body.dark .b33-profile-overlay[data-brand="zam"],
.b33-profile-overlay[data-theme="dark"][data-brand="zam"] {
  /* Light fill so primary CTAs stay visible on dark neu */
  --b33-ov-accent: #e8e4dc;
  --b33-ov-accent-wash: rgba(232, 228, 220, 0.14);
  --b33-ov-neu-accent:
    4px 6px 16px rgba(0, 0, 0, 0.45),
    -2px -2px 6px rgba(72, 80, 100, 0.25);
}

body.dark .b33-profile-overlay[data-brand="zam"] .btn-primary,
.b33-profile-overlay[data-theme="dark"][data-brand="zam"] .btn-primary {
  color: #1E2330;
}

body.dark .b33-profile-overlay[data-brand="zam"] .btn-danger,
body.dark .b33-profile-overlay[data-brand="zam"] button.btn-circle.btn-danger,
.b33-profile-overlay[data-theme="dark"][data-brand="zam"] .btn-danger,
.b33-profile-overlay[data-theme="dark"][data-brand="zam"] button.btn-circle.btn-danger {
  color: #e8e4dc;
  border-color: #e8e4dc;
}

.b33-profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  place-items: center;
  align-content: center;
  background: var(--b33-ov-scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
  padding-bottom: calc(24px + var(--b33-ov-safe-b));
  padding-top: calc(20px + var(--b33-ov-safe-t));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--b33-ov-font);
  color: var(--b33-ov-ink);
  box-sizing: border-box;
}

.b33-profile-overlay *,
.b33-profile-overlay *::before,
.b33-profile-overlay *::after {
  box-sizing: border-box;
}

/* display:flex/grid on controls must not override [hidden] */
.b33-profile-overlay [hidden] {
  display: none !important;
}

.b33-profile-overlay.is-open {
  display: grid;
}

.b33-profile-overlay-panel {
  width: min(520px, 100%);
  max-height: min(92dvh, 920px);
  display: flex;
  flex-direction: column;
  overflow: visible;
  border-radius: var(--b33-ov-radius);
  background: var(--b33-ov-neu-bg);
  border: none;
  box-shadow:
    0 18px 48px rgba(20, 16, 24, 0.32),
    0 4px 14px rgba(20, 16, 24, 0.18),
    var(--b33-ov-neu-lg);
  animation: b33ProfileIn 0.32s ease;
}

@keyframes b33ProfileIn {
  from { transform: translateY(24px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.b33-profile-overlay .profile-panel {
  margin: 0;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(92dvh, 920px);
  height: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: hidden;
  border-radius: var(--b33-ov-radius);
}

/* One neu card: title + back + all sections */
.b33-profile-overlay .profile-panel-frame {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(92dvh, 920px);
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.2vh, 22px);
  padding: clamp(18px, 2.4vh, 24px) clamp(18px, 3vw, 26px) clamp(28px, 3.6vh, 36px);
  border-radius: var(--b33-ov-radius);
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  isolation: isolate;
}

.b33-profile-overlay .profile-panel-loading {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  padding: clamp(24px, 4vh, 48px) 4px;
  margin: 0;
}

.b33-profile-overlay .profile-panel-stack,
.b33-profile-overlay [data-b33-body] {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(14px, 2.6vh, 28px);
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.b33-profile-overlay .profile-panel-stack > .panel-block {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.b33-profile-overlay .profile-panel-stack > .panel-block--quiet {
  margin-top: auto;
  padding: 8px 2px 14px;
}

.b33-profile-overlay .panel-block--quiet > [data-b33-logout] {
  width: 100%;
}

.b33-profile-overlay .topbar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin: 0;
}

.b33-profile-overlay .topbar h2 {
  margin: 0;
  font-size: calc(clamp(1.05rem, 2.8vh, 1.25rem) + 3px);
  font-weight: 700;
  text-align: center;
  justify-self: center;
  color: var(--b33-ov-ink);
}

.b33-profile-overlay .back-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--b33-ov-surface);
  box-shadow: var(--b33-ov-neu);
  color: var(--b33-ov-ink);
  font-size: 1.25rem;
  line-height: 1;
  font-family: inherit;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.b33-profile-overlay .back-btn:hover {
  transform: scale(1.04);
}

.b33-profile-overlay .back-btn:active {
  transform: scale(0.96);
  box-shadow: var(--b33-ov-neu-press);
}

.b33-profile-overlay .panel-block {
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  text-align: left;
}

.b33-profile-overlay .panel-block h3 {
  margin: 0 0 9px;
  font-size: calc(0.85rem + 4px);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--b33-ov-ink);
}

.b33-profile-overlay .panel-block--identity {
  padding-top: 0;
  padding-bottom: 0;
  text-align: center;
}

.b33-profile-overlay .profile-hero-avatar {
  width: clamp(72px, 12vh, 104px);
  height: clamp(72px, 12vh, 104px);
  border-radius: 50%;
  margin: 0 auto;
  overflow: hidden;
  background: var(--b33-ov-neu-bg);
  box-shadow:
    0 8px 22px rgba(47, 111, 237, 0.12),
    var(--b33-ov-neu-sm);
  padding: 0;
}

.b33-profile-overlay[data-brand="zad"] .profile-hero-avatar,
.b33-profile-overlay[data-brand="nya"] .profile-hero-avatar {
  box-shadow:
    0 8px 22px var(--b33-ov-accent-wash),
    var(--b33-ov-neu-sm);
}

.b33-profile-overlay .profile-hero-avatar img,
.b33-profile-overlay .profile-hero-avatar .avatar-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: grid;
  place-items: center;
  font-size: clamp(1.4rem, 3.5vh, 1.9rem);
  font-weight: 700;
  border-radius: 50%;
  background: transparent;
}

.b33-profile-overlay .muted {
  color: var(--b33-ov-muted);
  margin: 2px 0 0;
  font-size: 0.82rem;
}

.b33-profile-overlay .avatar-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(8px, 1.4vh, 12px);
  margin: clamp(8px, 1.4vh, 12px) 0;
}

.b33-profile-overlay .avatar-opt {
  appearance: none;
  border: none;
  background: var(--b33-ov-neu-bg);
  border-radius: 50%;
  aspect-ratio: 1;
  padding: 5px;
  cursor: pointer;
  overflow: visible;
  /* Raised neumorph for zam / zad / nya — same outset family as .btn-ghost */
  box-shadow: var(--b33-ov-neu);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.b33-profile-overlay .avatar-opt img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.b33-profile-overlay .avatar-opt:hover {
  transform: scale(1.06);
  box-shadow: var(--b33-ov-neu-sm);
}

.b33-profile-overlay .avatar-opt:active {
  transform: scale(0.96);
  box-shadow: var(--b33-ov-neu-press);
}

.b33-profile-overlay .avatar-opt.is-selected {
  box-shadow:
    var(--b33-ov-neu),
    0 0 0 2.5px var(--b33-ov-accent);
}

.b33-profile-overlay .avatar-opt.is-selected img {
  box-shadow: none;
}

.b33-profile-overlay .btn-circle {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  border-radius: 999px;
  min-height: 42px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.b33-profile-overlay .btn-circle:active {
  transform: scale(0.96);
}

.b33-profile-overlay .btn-primary {
  background: var(--b33-ov-accent);
  color: #fff;
  box-shadow: var(--b33-ov-neu-accent);
}

.b33-profile-overlay .btn-primary:hover {
  filter: brightness(1.04);
}

.b33-profile-overlay .btn-ghost {
  /* Slightly raised surface vs panel so outset reads clearly */
  background: var(--b33-ov-surface);
  color: var(--b33-ov-ink);
  box-shadow: var(--b33-ov-neu);
}

.b33-profile-overlay .btn-ghost:hover {
  box-shadow: var(--b33-ov-neu-sm);
  transform: translateY(-1px);
}

.b33-profile-overlay .btn-ghost:active {
  transform: scale(0.97);
  box-shadow: var(--b33-ov-neu-press);
}

.b33-profile-overlay .btn-danger,
.b33-profile-overlay button.btn-circle.btn-danger {
  background: var(--b33-ov-neu-bg);
  border: 1.5px solid var(--b33-ov-accent);
  color: var(--b33-ov-accent);
  box-shadow: var(--b33-ov-neu-sm);
}

.b33-profile-overlay .btn-danger:hover,
.b33-profile-overlay button.btn-circle.btn-danger:hover {
  background: var(--b33-ov-accent-wash);
  transform: translateY(-1px);
  box-shadow: var(--b33-ov-neu);
}

.b33-profile-overlay .btn-danger:active,
.b33-profile-overlay button.btn-circle.btn-danger:active {
  transform: scale(0.98);
  box-shadow: var(--b33-ov-neu-press);
}

.b33-profile-overlay .profile-upload {
  display: flex;
  width: 100%;
  margin-top: 17px;
  margin-bottom: 0;
  cursor: pointer;
}

.b33-profile-overlay .panel-block-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.b33-profile-overlay .panel-block-form input[type="password"],
.b33-profile-overlay .panel-block-form input[type="text"],
.b33-profile-overlay .panel-block-form input[type="email"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  margin: 6px 0;
  padding: 12px 18px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--b33-ov-ink);
  border-radius: 999px;
  border: none;
  background-color: var(--b33-ov-neu-bg);
  background-clip: padding-box;
  box-shadow: var(--b33-ov-neu-in);
  outline: none;
}

.b33-profile-overlay .panel-block-form input:focus {
  box-shadow: var(--b33-ov-neu-in), 0 0 0 3px var(--b33-ov-accent-wash);
}

.b33-profile-overlay .panel-block-form .btn-circle {
  margin-top: 4px;
  width: 100%;
}

.b33-profile-overlay .panel-block--accent .btn-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 22px;
  margin-top: 18px;
}

.b33-profile-overlay .panel-block--accent .btn-circle {
  width: 100%;
  min-height: 52px;
  padding: 0 22px;
  font-size: calc(1.15rem - 4px);
}

.b33-profile-overlay .logout-confirm {
  display: grid;
  gap: 14px;
  width: 100%;
}

.b33-profile-overlay .logout-confirm-msg {
  margin: 0;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
}

.b33-profile-overlay .logout-confirm .btn-row {
  display: flex;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 10px;
  justify-content: stretch;
}

.b33-profile-overlay .logout-confirm .btn-row .btn-circle {
  flex: 1 1 0;
  min-width: 0;
  margin-top: 0;
  min-height: 48px;
}

.b33-profile-overlay .b33-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--b33-ov-safe-b));
  transform: translateX(-50%);
  z-index: 10001;
  background: var(--b33-ov-surface);
  color: var(--b33-ov-ink);
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: var(--b33-ov-neu);
  pointer-events: none;
}

.b33-profile-overlay .b33-toast[hidden] {
  display: none !important;
}

.b33-profile-overlay .panel-block--crossapp {
  margin-top: 4px;
}

.b33-profile-overlay .crossapp-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 20px;
  background: var(--b33-ov-surface);
  box-shadow: var(--b33-ov-neu-sm);
  color: inherit;
  text-decoration: none;
  box-sizing: border-box;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.b33-profile-overlay .crossapp-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--b33-ov-neu);
}

.b33-profile-overlay .crossapp-card:active {
  transform: scale(0.98);
  box-shadow: var(--b33-ov-neu-press);
}

.b33-profile-overlay .crossapp-logo {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--b33-ov-neu-bg);
  display: grid;
  place-items: center;
}

.b33-profile-overlay .crossapp-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.b33-profile-overlay .crossapp-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
  text-align: left;
}

.b33-profile-overlay .crossapp-name {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.25;
  color: var(--b33-ov-ink);
}

.b33-profile-overlay .crossapp-tagline {
  font-size: 0.76rem;
  line-height: 1.3;
  color: var(--b33-ov-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.b33-profile-overlay .crossapp-arrow {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--b33-ov-accent);
  opacity: 0.7;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.b33-profile-overlay .crossapp-card:hover .crossapp-arrow {
  opacity: 1;
  transform: translate(1px, -1px);
}

.b33-profile-overlay .profile-legal-footer {
  display: grid;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
  padding: 14px 4px 4px;
  text-align: center;
}

.b33-profile-overlay .profile-legal-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 8px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.b33-profile-overlay .profile-legal-links a {
  color: var(--b33-ov-accent, #c24a36);
  font-weight: 700;
  text-decoration: none;
}

.b33-profile-overlay .profile-legal-links a:hover {
  text-decoration: underline;
}

.b33-profile-overlay .profile-legal-sep {
  color: var(--b33-ov-muted, #6b6b6b);
  opacity: 0.55;
}

.b33-profile-overlay .profile-legal-copy {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--b33-ov-muted, #6b6b6b);
}

@media (max-height: 700px) {
  .b33-profile-overlay-panel {
    height: auto;
  }

  .b33-profile-overlay .profile-panel-frame {
    gap: 12px;
    padding: 16px 18px 28px;
  }

  .b33-profile-overlay .profile-panel-stack,
  .b33-profile-overlay [data-b33-body] {
    justify-content: flex-start;
    gap: 12px;
    padding: 0;
  }

  .b33-profile-overlay .profile-hero-avatar {
    width: 64px;
    height: 64px;
  }

  .b33-profile-overlay .panel-block {
    padding: 0;
  }
}

/* Full-page profile shell using same panel */
body.b33-profile-page {
  margin: 0;
  min-height: 100%;
  font-family: "Comfortaa", system-ui, sans-serif;
  color: #1e2330;
  background: #f6eadf;
}

body.b33-profile-page[data-brand="zam"] {
  background: #f6eadf;
}

body.b33-profile-page[data-brand="nya"] {
  background: #f0f5f2;
}

body.b33-profile-page[data-brand="zad"] {
  background: #f6eadf;
}

body.b33-profile-page.dark,
body.dark.b33-profile-page {
  color: #e8e4dc;
  background: #1b1e27;
}

.b33-profile-page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px 40px;
}

.b33-profile-page-shell .profile-panel {
  width: min(520px, 100%);
  min-height: min(88dvh, 880px);
  padding: 0;
  display: flex;
  flex-direction: column;
}

.b33-profile-page-shell .profile-panel-frame {
  flex: 1 1 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.2vh, 22px);
  padding: clamp(18px, 2.4vh, 24px) clamp(18px, 3vw, 26px) clamp(28px, 3.6vh, 36px);
  border-radius: var(--b33-ov-radius, 28px);
  background: var(--b33-ov-neu-bg, #f6eadf);
  border: none;
  box-shadow:
    0 18px 48px rgba(20, 16, 24, 0.14),
    var(--b33-ov-neu-lg, 4px 4px 10px #ccc2b9, -3px -3px 8px #ffffff);
}

.b33-profile-page-shell .profile-panel-stack {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(14px, 2.6vh, 28px);
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}
