    :root {
      --bg: #0d1117;
      --card: transparent;
      --border: rgba(255, 105, 180, 0.25);
      --accent: #ff69b4;
      --accent-glow: rgba(255, 105, 180, 0.5);
      --text: #f0f6fc;
      --text-muted: #8b949e;
      --green: #2ea043;
      --red: #f85149;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
    body {
      background: radial-gradient(circle at 50% 20%, #2b1836 0%, #0d1117 80%);
      color: var(--text);
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }
    .card {
      position: relative;
      z-index: 2;
      background: transparent;
      border: none;
      border-radius: 0;
      padding: 20px 16px;
      max-width: 440px;
      width: 100%;
      text-align: center;
      box-shadow: none;
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
    }
    .avatar-container {
      position: relative;
      width: 170px;
      height: 170px;
      margin: 0 auto 24px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .avatar-halo {
      position: absolute;
      width: 100%;
      height: 100%;
      border-radius: 50%;
      background: conic-gradient(from 0deg, #ff69b4, #ff1493, #a855f7, #ff69b4);
      filter: blur(8px);
      opacity: 0.6;
      animation: rotateHalo 8s linear infinite;
      z-index: 1;
    }
    .avatar-img-wrap {
      position: relative;
      width: 156px;
      height: 156px;
      border-radius: 50%;
      padding: 3px;
      background: linear-gradient(135deg, #ff69b4, #a855f7);
      z-index: 2;
      overflow: hidden;
      box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    }
    /* Постоянная базовая фоновая подложка лица Ляси (исключает любое мерцание и просветы) */
    .avatar-base-bg {
      position: absolute;
      top: 3px;
      left: 3px;
      width: calc(100% - 6px);
      height: calc(100% - 6px);
      border-radius: 50%;
      object-fit: cover;
      display: block;
      z-index: 1;
      pointer-events: none;
      transform: translateZ(0);
      will-change: transform;
    }
    .avatar-img {
      position: absolute;
      top: 3px;
      left: 3px;
      width: calc(100% - 6px);
      height: calc(100% - 6px);
      border-radius: 50%;
      object-fit: cover;
      display: block;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.18s ease-in-out;
      z-index: 2;
      transform: translateZ(0);
      will-change: opacity;
    }
    .avatar-img.active {
      opacity: 1;
    }
    .avatar-container.talking .avatar-img-wrap { transform: scale(1.04); transition: transform 0.15s ease; }
    .avatar-container.talking .avatar-halo {
      opacity: 1;
      filter: blur(12px);
      animation: rotateHalo 3s linear infinite, pulseGlow 1.2s infinite alternate ease-in-out;
    }
    @keyframes rotateHalo { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
    @keyframes pulseGlow { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(1.15); opacity: 1; } }
    .status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; background: rgba(255,255,255,0.05); border-radius: 20px; font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
    .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
    .status-dot.active { background: var(--green); box-shadow: 0 0 8px var(--green); }
    h1 { font-size: 22px; margin-bottom: 6px; }
    p.desc { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.4; }
    .btn-main {
      width: 100%;
      padding: 16px;
      border-radius: 16px;
      background: linear-gradient(135deg, #ff69b4, #ff1493);
      border: none;
      color: white;
      font-size: 16px;
      font-weight: 600;
      cursor: pointer;
      box-shadow: 0 4px 20px var(--accent-glow);
      transition: transform 0.1s, opacity 0.2s, background 0.3s;
    }
    .btn-main:active { transform: scale(0.98); }
    .btn-main:disabled { opacity: 0.5; cursor: not-allowed; }

    /* Блок селектора пользователя и инпута с валидацией */
    .user-auth-box {
      margin: 12px 0;
      width: 100%;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .user-btn-grid {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      justify-content: center;
    }
    .user-chip-wrap {
      display: inline-flex;
      align-items: center;
      background: rgba(255, 105, 180, 0.15);
      border: 1px solid rgba(255, 105, 180, 0.35);
      border-radius: 14px;
      padding: 0;
      transition: all 0.2s;
    }
    .user-chip-wrap:hover {
      background: rgba(255, 105, 180, 0.25);
      border-color: rgba(255, 105, 180, 0.6);
    }
    .btn-user-select {
      padding: 10px 14px;
      border: none;
      background: transparent;
      color: #ff69b4;
      font-size: 15px;
      font-weight: 600;
      cursor: pointer;
      border-radius: 14px 0 0 14px;
      display: flex;
      align-items: center;
    }
    .btn-user-delete {
      padding: 10px 10px;
      border: none;
      background: transparent;
      color: rgba(255, 105, 180, 0.6);
      font-size: 14px;
      cursor: pointer;
      border-radius: 0 14px 14px 0;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: color 0.15s, transform 0.15s;
    }
    .btn-user-delete:hover {
      color: #ff4d4f;
      transform: scale(1.15);
    }
    .user-input-row {
      position: relative;
      display: flex;
      align-items: center;
      width: 100%;
    }
    .user-name-input {
      width: 100%;
      padding: 12px 48px 12px 16px;
      border-radius: 14px;
      background: rgba(22, 27, 34, 0.95);
      border: 1.5px solid rgba(88, 166, 255, 0.3);
      color: #f0f6fc;
      font-size: 14px;
      outline: none;
      transition: border-color 0.2s, box-shadow 0.2s;
      box-sizing: border-box;
    }
    .user-name-input:focus {
      border-color: #58a6ff;
      box-shadow: 0 0 10px rgba(88, 166, 255, 0.25);
    }
    .user-name-input.input-error {
      border-color: #f85149 !important;
      box-shadow: 0 0 10px rgba(248, 81, 73, 0.3) !important;
    }
    .btn-submit-name {
      position: absolute;
      right: 6px;
      top: 50%;
      transform: translateY(-50%);
      width: 36px;
      height: 36px;
      border-radius: 10px;
      border: none;
      background: linear-gradient(135deg, #ff69b4, #ff1493);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: transform 0.15s, opacity 0.15s;
    }
    .btn-submit-name:hover {
      transform: translateY(-50%) scale(1.06);
    }
    .btn-submit-name:active {
      transform: translateY(-50%) scale(0.95);
    }
    .input-error-msg {
      color: #ff7b72;
      font-size: 11px;
      text-align: left;
      padding-left: 6px;
      display: none;
    }

    /* Панель управления зрением (камерой) */
    .vision-panel {
      display: none;
      margin-top: 12px;
      gap: 8px;
      width: 100%;
    }
    .btn-vision {
      flex: 1;
      padding: 14px 12px;
      border-radius: 16px;
      font-size: 15px;
      font-weight: 600;
      border: 1px solid rgba(255, 105, 180, 0.4);
      background: rgba(255, 105, 180, 0.12);
      color: #ff69b4;
      cursor: pointer;
      transition: all 0.2s;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
    }
    .btn-vision.active {
      background: linear-gradient(135deg, #a855f7, #ec4899);
      color: white;
      border: none;
      box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
    }
    .btn-flip {
      padding: 14px 16px;
      border-radius: 16px;
      font-size: 13px;
      font-weight: 600;
      border: 1px solid rgba(255, 255, 255, 0.15);
      background: rgba(255, 255, 255, 0.06);
      color: #c9d1d9;
      cursor: pointer;
      transition: all 0.2s;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      white-space: nowrap;
    }
    .btn-flip:active, .btn-vision:active { transform: scale(0.96); }

    /* Панель пространства и управления памятью */
    .space-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 14px;
      padding: 6px 12px;
      margin-bottom: 14px;
      font-size: 12px;
    }
    .user-pill {
      padding: 4px 10px;
      border-radius: 8px;
      background: rgba(255, 105, 180, 0.15);
      border: 1px solid rgba(255, 105, 180, 0.3);
      color: #ff69b4;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s;
    }
    .user-pill.active {
      background: #ff69b4;
      color: #0d1117;
    }
    .btn-action-row {
      display: flex;
      gap: 8px;
      margin-top: 10px;
      width: 100%;
    }
    .btn-action {
      flex: 1;
      padding: 10px 8px;
      border-radius: 12px;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      border: 1px solid rgba(255, 255, 255, 0.15);
      background: rgba(255, 255, 255, 0.05);
      color: #c9d1d9;
      transition: all 0.2s;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 5px;
    }
    .btn-action:hover { background: rgba(255, 255, 255, 0.1); }
    .btn-action:active { transform: scale(0.97); }
    .btn-save-mem {
      border-color: rgba(46, 160, 67, 0.4);
      background: rgba(46, 160, 67, 0.15);
      color: #3fb950;
    }
    .btn-clear-mem {
      border-color: rgba(248, 81, 73, 0.4);
      background: rgba(248, 81, 73, 0.15);
      color: #ff7b72;
    }

    /* Модальное окно камеры на весь экран (Шеринг UX) */
    .camera-modal {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      background: #000;
      z-index: 9999;
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      user-select: none;
      -webkit-user-select: none;
    }
    .camera-modal.open { display: flex; }
    .camera-video {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .camera-video.no-mirror {
      transform: scaleX(1);
    }

    /* Полупрозрачная маска-видоискатель со скругленной белой рамкой */
    .camera-overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: flex-start; /* От верха */
      padding-top: calc(env(safe-area-inset-top, 16px) + 72px); /* Аккуратно под верхней панелью кнопок */
      box-sizing: border-box;
      z-index: 10000;
    }

    .camera-frame-box {
      width: 88vw;
      max-width: 440px;
      height: 60vh; /* Увеличено по высоте */
      position: relative;
      box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.48); /* Затемнение фона вокруг рамки */
      border-radius: 40px;
    }

    /* 4 акцентных жирных скругленных угла как в шеринге (ещё толще и выразительнее) */
    .camera-frame-corner {
      position: absolute;
      width: 64px;
      height: 64px;
      border: 8px solid #ffffff; /* Ультра-жирные: 8px */
      pointer-events: none;
    }
    .camera-frame-corner.top-left {
      top: -4px;
      left: -4px;
      border-right: none;
      border-bottom: none;
      border-top-left-radius: 40px;
    }
    .camera-frame-corner.top-right {
      top: -4px;
      right: -4px;
      border-left: none;
      border-bottom: none;
      border-top-right-radius: 40px;
    }
    .camera-frame-corner.bottom-left {
      bottom: -4px;
      left: -4px;
      border-right: none;
      border-top: none;
      border-bottom-left-radius: 40px;
    }
    .camera-frame-corner.bottom-right {
      bottom: -4px;
      right: -4px;
      border-left: none;
      border-top: none;
      border-bottom-right-radius: 40px;
    }

    /* Верхняя панель: смена камеры и закрытие */
    .camera-controls-top {
      position: absolute;
      top: calc(env(safe-area-inset-top, 16px) + 16px);
      left: 0;
      width: 100%;
      padding: 0 20px;
      box-sizing: border-box;
      z-index: 10002;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .camera-pill-btn {
      background: rgba(20, 24, 33, 0.65);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      border: 1px solid rgba(255, 255, 255, 0.25);
      color: #fff;
      padding: 8px 14px;
      border-radius: 22px;
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      transition: background 0.2s, transform 0.15s;
    }
    .camera-pill-btn:active { transform: scale(0.94); background: rgba(255, 255, 255, 0.25); }

    /* Нижняя панель управления: миниатюра слева, спуск по центру, кнопка "Готово" справа */
    .camera-controls-bottom {
      position: absolute;
      bottom: calc(env(safe-area-inset-bottom, 24px) + 95px); /* Ещё выше подняли (+95px) над навигацией */
      left: 0;
      width: 100%;
      padding: 0 24px;
      box-sizing: border-box;
      z-index: 10002;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    /* Слот под миниатюру слева (вертикальный формат 3:4) */
    .camera-thumb-slot {
      width: 54px;
      height: 72px; /* 3:4 пропорция */
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .camera-thumb-preview {
      width: 54px;
      height: 72px; /* 3:4 пропорция */
      border-radius: 12px;
      border: 2px solid #fff;
      object-fit: cover;
      display: none;
      box-shadow: 0 4px 14px rgba(0,0,0,0.5);
    }

    .camera-thumb-delete {
      position: absolute;
      top: -6px;
      right: -6px;
      width: 22px;
      height: 22px;
      background: #ff4757;
      color: #fff;
      border-radius: 50%;
      display: none;
      align-items: center;
      justify-content: center;
      font-size: 12px;
      font-weight: bold;
      cursor: pointer;
      border: 2px solid #fff;
      box-shadow: 0 2px 6px rgba(0,0,0,0.4);
      z-index: 10003;
    }
    .camera-thumb-delete:active { transform: scale(0.9); }

    /* Кнопка спуска по центру */
    .camera-btn-round {
      width: 76px;
      height: 76px;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.2);
      border: 4px solid #fff;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: transform 0.15s, background 0.15s;
    }
    .camera-btn-round:active { transform: scale(0.92); background: rgba(255, 255, 255, 0.4); }
    .camera-btn-circle-inner {
      width: 58px;
      height: 58px;
      border-radius: 50%;
      background: #fff;
    }

    /* Кнопка "Готово" справа */
    .camera-done-btn {
      background: #ffcc00;
      color: #111;
      font-weight: 700;
      font-size: 15px;
      padding: 12px 20px;
      border-radius: 22px;
      border: none;
      cursor: pointer;
      display: none; /* появляется когда есть снимок */
      align-items: center;
      gap: 6px;
      box-shadow: 0 4px 14px rgba(0,0,0,0.4);
      transition: transform 0.15s, background 0.2s;
    }
    .camera-done-btn:active { transform: scale(0.95); background: #e6b800; }

    /* Анимированная летящая копия снимка при клике на затвор */
    .flying-snap {
      position: fixed;
      z-index: 10005;
      border: 2px solid #fff;
      border-radius: 20px;
      object-fit: cover;
      pointer-events: none;
      transition: all 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    /* Инженерная панель эмоций и биоритма (PAD Monitor) */
    .mood-monitor-box {
      margin: 8px 0 10px 0;
      background: rgba(13, 17, 23, 0.94);
      border: 1px solid rgba(168, 85, 247, 0.45);
      border-radius: 12px;
      font-size: 11px;
      text-align: left;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    }
    .mood-bar-wrap {
      height: 6px;
      background: rgba(255, 255, 255, 0.1);
      border-radius: 3px;
      overflow: hidden;
      margin-top: 3px;
    }
    .mood-bar-fill {
      height: 100%;
      border-radius: 3px;
      transition: width 0.4s ease;
    }
