*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --tg-blue: #2aabee;
  --tg-blue-dark: #229ed9;
  --bg-app: #0e1117;
  --bg-panel: #161b22;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --border: #30363d;
  --phone-bg: #ffffff;
  --phone-text: #000000;
  --phone-muted: #707579;
  --kb-bg: #d1d5db;
  --kb-key: #ffffff;
  --kb-key-active: #acb4bc;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
}

html, body {
  height: 100%;
  overflow: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Scroll without visible browser scrollbar */
.app,
.setup-panel {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.app::-webkit-scrollbar,
.setup-panel::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Внутри макета телефона — home, профиль, лента, edit и т.д. */
.phone-screen,
.phone-screen * {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.phone-screen *::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-app);
  color: var(--text);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100dvh;
}

.header {
  flex-shrink: 0;
  padding: 1rem 1.5rem 0.5rem;
  text-align: center;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.subtitle {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.by-sourness {
  font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1;
  letter-spacing: 0.06em;
  background: linear-gradient(120deg, #f0f6fc 8%, #c9d1d9 42%, #8b949e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 24px rgba(230, 237, 243, 0.12);
}

.subtitle-dot {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  opacity: 0.45;
  user-select: none;
}

.platform-link {
  color: var(--tg-blue);
  text-decoration: none;
}

.platform-link:hover {
  text-decoration: underline;
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 1.5rem;
  padding: 1rem 1.5rem 1.5rem;
  min-height: 0;
  overflow: hidden;
}

.setup-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

.setup-panel h2 {
  font-size: 1rem;
  font-weight: 600;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.setup-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.setup-form label span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.setup-form input {
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s var(--ease);
}

.setup-form input:focus {
  outline: none;
  border-color: var(--tg-blue);
}

.controls {
  display: flex;
  gap: 0.5rem;
}

.btn {
  flex: 1;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s var(--ease);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:not(:disabled):hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--tg-blue);
  color: #fff;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.progress-block {
  margin-top: auto;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--tg-blue);
  border-radius: 2px;
  transition: width 0.5s var(--ease-in-out);
}

.scene-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.disclaimer {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.phone-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

.phone-frame {
  position: relative;
  width: min(320px, 86vw, calc((85dvh - 24px) * 9 / 19.5));
  aspect-ratio: 9 / 19.5;
  max-height: 85dvh;
  height: auto;
  flex-shrink: 0;
  background: #1a1a1a;
  border-radius: 44px;
  padding: 12px;
  box-shadow:
    0 0 0 2px #333,
    0 0 0 4px #1a1a1a,
    0 25px 80px rgba(0, 0, 0, 0.6),
    inset 0 0 20px rgba(255, 255, 255, 0.03);
}

.phone-notch {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 28px;
  background: #1a1a1a;
  border-radius: 0 0 18px 18px;
  z-index: 46;
  pointer-events: none;
}

.phone-screen {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--phone-bg);
  border-radius: 32px;
  overflow: hidden;
}

/* iPhone Status Bar */
.iphone-status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  padding: 9px 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 45;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  transition: color 0.35s var(--ease-in-out);
}

.iphone-status-bar[data-theme="light"] {
  color: #000;
}

.iphone-status-bar[data-theme="dark"] {
  color: #fff;
}

.status-bar-side {
  display: flex;
  align-items: center;
  min-height: 15px;
}

.status-bar-left {
  flex: 1;
  padding-right: 56px;
}

.status-bar-right {
  flex: 1;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
  padding-left: 56px;
}

.status-clock {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* Status bar icons (SVG) */
.sb-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: inherit;
  line-height: 0;
  overflow: visible;
}

.sb-icon svg {
  display: block;
}

.sb-cellular svg {
  width: 19px;
  height: 15px;
}

.sb-cellular .cell-bar {
  fill: currentColor;
}

.sb-cellular .cell-bar-dim {
  opacity: 0.28;
}

.sb-cellular .cell-dot {
  fill: currentColor;
}

.sb-battery svg {
  width: 28px;
  height: 13px;
}

.sb-battery .battery-fill {
  fill: currentColor;
  transition: width 0.35s ease;
}

.sb-battery[data-tier="low"] .battery-fill {
  fill: #ff3b30;
}

.sb-battery[data-tier="mid"] .battery-fill {
  fill: #3a3a3c;
}

.iphone-status-bar[data-theme="dark"] .sb-battery[data-tier="low"] .battery-fill {
  fill: #ff453a;
}

.sb-cellular.signal-pulse .cell-bar-dim {
  animation: cell-bar-pulse 0.45s ease-out;
}

@keyframes cell-bar-pulse {
  0%, 100% { opacity: 0.28; }
  50% { opacity: 0.7; }
}

.phone-home-indicator {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 4px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 2px;
  z-index: 20;
}

.phone-frame:has(.scene-home.active) .phone-home-indicator {
  background: rgba(255, 255, 255, 0.55);
}

/* Scenes */
.scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--phone-bg);
  color: var(--phone-text);
  opacity: 0;
  visibility: hidden;
  transform: none;
  filter: none;
  transition: opacity 0.1s ease, visibility 0.1s;
  pointer-events: none;
  z-index: 1;
}

.scene.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
}

.scene.exit-left,
.scene.exit-fade {
  opacity: 0;
  transform: none;
  filter: none;
  z-index: 1;
}

.scene.enter-up {
  transform: none;
  opacity: 0;
}

.scene.enter-up.active {
  opacity: 1;
}

.scene-scroll {
  flex: 1;
  padding: 48px 18px 8px;
  overflow-y: auto;
  min-height: 0;
}

.phone-screen.keyboard-visible .scene-with-keyboard.active .scene-scroll {
  padding-bottom: 200px;
}

.phone-screen:has(.phone-tab-bar.is-visible) .phone-home-indicator {
  opacity: 0.35;
}

.phone-keyboard.is-visible {
  transform: translateY(0) !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Scene 1: Login */
.scene-login {
  align-items: stretch;
}

.scene-login .scene-scroll {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 48px;
}

.phone-screen.keyboard-visible .scene-login .scene-scroll {
  padding-top: 36px;
}

.tg-logo {
  margin-bottom: 8px;
}

.tg-logo img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: transparent;
}

.scene-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.scene-desc {
  font-size: 0.8rem;
  color: var(--phone-muted);
  text-align: center;
  margin-bottom: 20px;
}

.input-field {
  position: relative;
  width: 100%;
  border-bottom: 2px solid var(--tg-blue);
  padding: 6px 0 8px;
  margin-bottom: 20px;
  height: 52px;
  flex-shrink: 0;
  overflow: hidden;
}

.field-label {
  display: block;
  font-size: 0.7rem;
  color: var(--tg-blue);
  margin-bottom: 2px;
  line-height: 1.2;
}

.field-value-row {
  display: flex;
  align-items: center;
  height: 26px;
  overflow: hidden;
  white-space: nowrap;
}

.field-value {
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  line-height: 26px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.field-value.clear {
  filter: none;
  user-select: none;
}

.field-caret {
  display: inline-block;
  width: 2px;
  height: 22px;
  flex-shrink: 0;
  background: var(--tg-blue);
  margin-left: 2px;
  animation: blink 1s step-end infinite;
}

.field-caret.hidden {
  display: none;
}

@keyframes blink {
  50% { opacity: 0; }
}

.phone-hint.clear {
  font-size: 0.88rem;
  color: var(--phone-text);
  margin-bottom: 24px;
  align-self: center;
  text-align: center;
  filter: none;
}

.tg-btn {
  width: 100%;
  padding: 12px;
  background: var(--tg-blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: default;
  transition: background 0.2s, transform 0.15s var(--ease);
}

.tg-btn.pressed {
  transform: scale(0.97);
  background: var(--tg-blue-dark);
}

.tg-btn.loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Scene 2: SMS — centered */
.scene-centered {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 52px !important;
  text-align: center;
}

.sms-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.scene-sms .scene-title,
.scene-sms .scene-desc,
.scene-sms .phone-hint {
  width: 100%;
  text-align: center;
}

.scene-sms .scene-desc {
  margin-bottom: 8px;
}

.scene-sms .phone-hint {
  margin-bottom: 28px;
}

.phone-screen.keyboard-visible .scene-centered {
  padding-top: 40px !important;
}

.back-btn, .header-icon-btn {
  background: none;
  border: none;
  color: var(--tg-blue);
  margin-bottom: 12px;
  cursor: default;
  padding: 0;
  display: flex;
  align-items: center;
}

.back-btn svg,
.header-icon-btn svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.25;
}

.code-boxes {
  display: flex;
  gap: 8px;
  align-self: center;
  margin: 0 auto;
}

.code-digit {
  width: 40px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 600;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  transition: border-color 0.2s, background 0.2s;
  color: var(--phone-text);
}

.code-digit.filled {
  border-color: var(--tg-blue);
  background: rgba(42, 171, 238, 0.08);
  animation: digit-pop 0.25s var(--ease);
}

@keyframes digit-pop {
  0% { transform: scale(0.9); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* iOS keyboard — dark theme (user reference) */
.phone-keyboard {
  --kb-bg: #1c1c1c;
  --kb-key: #505050;
  --kb-key-active: #6a6a6a;
  --kb-text: #ffffff;
  --kb-glow: rgba(255, 255, 255, 0.22);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--kb-bg);
  padding: 8px 6px 14px;
  border-top: 0.5px solid rgba(255, 255, 255, 0.06);
  transform: translateY(105%);
  opacity: 0;
  visibility: hidden;
  transition:
    transform 0.55s cubic-bezier(0.25, 0.8, 0.25, 1),
    opacity 0.4s var(--ease-in-out),
    visibility 0.4s;
  z-index: 30;
  touch-action: manipulation;
  user-select: none;
}

.phone-keyboard.is-visible {
  box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.35);
}

.kb-panels {
  position: relative;
  min-height: 188px;
}

.kb-panel {
  display: none;
  flex-direction: column;
  gap: 6px;
}

.kb-panel.active {
  display: flex;
}

.kb-panels.is-switching .kb-panel.active {
  animation: kb-panel-in 0.2s var(--ease-in-out);
}

@keyframes kb-panel-in {
  from {
    opacity: 0.55;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.kb-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 0 3px;
}

.kb-row-indent {
  padding-left: 16px;
  padding-right: 16px;
}

.kb-key {
  flex: 1;
  min-width: 0;
  height: 42px;
  max-width: none;
  background: var(--kb-key);
  border: none;
  border-radius: 6px;
  font-size: 1.12rem;
  font-weight: 400;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', sans-serif;
  color: var(--kb-text);
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s cubic-bezier(0.34, 1.45, 0.64, 1), background 0.08s;
  -webkit-tap-highlight-color: transparent;
}

.kb-panel[data-panel="letters"] .kb-key.kb-char {
  max-width: 32px;
}

.kb-shift-active .kb-key.kb-char {
  text-transform: uppercase;
}

.kb-key.kb-fn,
.kb-key.kb-mode,
.kb-key.kb-shift,
.kb-key.kb-backspace,
.kb-key.kb-emoji,
.kb-key.kb-return {
  background: var(--kb-key);
  color: var(--kb-text);
  max-width: none;
}

.kb-key.kb-mode {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.kb-key.kb-space {
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: lowercase;
  color: var(--kb-text);
}

.kb-key.kb-return {
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: lowercase;
}

/* Row 3: #+=  . , ? ! '  ⌫ */
.kb-row-mid .kb-mode {
  flex: 0 0 42px;
  min-width: 42px;
  max-width: 42px;
}

.kb-row-mid .kb-backspace {
  flex: 0 0 48px;
  min-width: 48px;
  max-width: 48px;
}

/* Row 4: ABC  😊  space  return */
.kb-row-bottom {
  gap: 6px;
  padding: 0 3px;
}

.kb-row-bottom .kb-mode {
  flex: 0 0 44px;
  min-width: 44px;
  max-width: 44px;
  font-size: 0.7rem;
}

.kb-row-bottom .kb-emoji {
  flex: 0 0 44px;
  min-width: 44px;
  max-width: 44px;
}

.kb-row-bottom .kb-space {
  flex: 1 1 0;
  min-width: 0;
}

.kb-row-bottom .kb-return {
  flex: 0 0 72px;
  min-width: 72px;
  max-width: 72px;
}

.kb-panel[data-panel="letters"] .kb-row-bottom .kb-shift {
  flex: 0 0 44px;
  min-width: 44px;
  max-width: 44px;
}

.kb-panel[data-panel="letters"] .kb-row-bottom .kb-backspace {
  flex: 0 0 48px;
  min-width: 48px;
  max-width: 48px;
}

.kb-key.pressed {
  animation: key-bounce 0.2s cubic-bezier(0.34, 1.45, 0.64, 1) forwards;
  background: var(--kb-key-active);
}

@keyframes key-bounce {
  0% { transform: scale(1); }
  40% { transform: scale(0.94); }
  100% { transform: scale(0.96); }
}

.kb-key.glow {
  box-shadow: 0 0 0 2px var(--kb-glow);
}

.kb-icon {
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.kb-icon-delete {
  width: 26px;
  height: 18px;
}

.kb-key.kb-backspace {
  padding: 0 4px;
}

.kb-icon-emoji {
  width: 24px;
  height: 24px;
}

/* Scene 3: Chats */
.scene-with-tabs {
  padding-bottom: 54px;
}

.scene-chats {
  padding-top: 44px;
}

.chats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 10px;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
  background: var(--phone-bg);
  z-index: 3;
}

.chats-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex: 1;
  text-align: center;
}

.header-icon-btn {
  margin-bottom: 0;
  width: 36px;
  height: 36px;
  justify-content: center;
  color: var(--tg-blue);
}

.chats-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  min-height: 64px;
  border-bottom: 1px solid #f0f0f0;
}

.chat-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chat-body {
  flex: 1;
  min-width: 0;
}

.chat-name {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
}

.chat-preview {
  font-size: 0.82rem;
  color: var(--phone-muted);
  margin-top: 3px;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.chat-time {
  font-size: 0.68rem;
  color: var(--phone-muted);
}

.chat-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: var(--tg-blue);
  border-radius: 10px;
  font-size: 0.65rem;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

/* Bottom tab bar */
.phone-tab-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 54px;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  background: rgba(247, 247, 247, 0.98);
  border-top: 0.5px solid rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 28;
  transform: translateY(100%);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.3s, visibility 0.3s;
  padding-bottom: 2px;
}

.phone-tab-bar.is-visible {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

.phone-tab-bar.tab-switching {
  transition: transform 0.48s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.35s;
}

.phone-tab-bar.tab-switching .tab-item:not(.active) {
  opacity: 0.55;
  transition: opacity 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  color: #8e8e93;
  font-size: 0.58rem;
  font-weight: 500;
  font-family: inherit;
  cursor: default;
  padding: 4px 2px 0;
  transition: color 0.2s, transform 0.15s;
}

.tab-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.75;
}

.tab-item.active {
  color: var(--tg-blue);
}

.tab-item.active svg {
  stroke: var(--tg-blue);
  fill: rgba(42, 171, 238, 0.12);
}

.tab-item.tab-pressed {
  transform: scale(0.88);
  transition: transform 0.18s cubic-bezier(0.34, 1.2, 0.64, 1), color 0.2s;
}

.tab-item[data-tab="settings"].tab-pressed {
  color: var(--tg-blue);
}

/* Scene 4: Settings */
.scene-profile {
  padding-top: 44px;
  overflow-y: auto;
  overflow-x: hidden;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px 14px;
  text-align: center;
  border-bottom: 8px solid #f2f2f7;
}

.profile-avatar-wrap {
  margin-bottom: 8px;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  background: #e8e8e8;
}

.profile-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  max-width: 100%;
}

.profile-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.name-badge-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
  display: none;
}

.name-badge-icon.is-visible {
  display: block;
}

/* Privacy blur — only fake chats list, not own profile/settings */
.scene-chats .privacy-blur-text {
  filter: blur(7px);
  opacity: 0.65;
  user-select: none;
}

.scene-chats .chat-preview {
  filter: blur(4.5px);
  opacity: 0.82;
}

.scene-chats .privacy-blur-avatar {
  position: relative;
  overflow: hidden;
  border-radius: 50%;
  filter: blur(4px);
  transform: translateZ(0);
  user-select: none;
}

.scene-chats .avatar-color-blobs {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 50%;
  background:
    radial-gradient(ellipse 58% 52% at 32% 30%, var(--blob1) 0%, transparent 68%),
    radial-gradient(ellipse 48% 46% at 74% 72%, var(--blob2) 0%, transparent 65%),
    radial-gradient(ellipse 35% 30% at 55% 45%, var(--blob3, var(--blob1)) 0%, transparent 55%),
    linear-gradient(145deg, var(--base1) 0%, var(--base2) 100%);
}

.scene-chats .chat-item:nth-child(10n + 1) .chat-avatar { --blob1: #f0b890; --blob2: #6a9fd4; --blob3: #8bc48a; --base1: #d4956a; --base2: #4a7a9e; }
.scene-chats .chat-item:nth-child(10n + 2) .chat-avatar { --blob1: #e88a9a; --blob2: #9b7ed9; --blob3: #f5c878; --base1: #b85a6e; --base2: #5c4a8a; }
.scene-chats .chat-item:nth-child(10n + 3) .chat-avatar { --blob1: #7ec8a0; --blob2: #5ab0d4; --blob3: #c8e878; --base1: #3d8a62; --base2: #2a6a88; }
.scene-chats .chat-item:nth-child(10n + 4) .chat-avatar { --blob1: #a8b0f0; --blob2: #f0a0c0; --blob3: #88d0e8; --base1: #6a72b8; --base2: #9a5a78; }
.scene-chats .chat-item:nth-child(10n + 5) .chat-avatar { --blob1: #90d8c8; --blob2: #78a8f0; --blob3: #e8d080; --base1: #3a9888; --base2: #4a68a8; }
.scene-chats .chat-item:nth-child(10n + 6) .chat-avatar { --blob1: #f0a878; --blob2: #d87898; --blob3: #88c0e0; --base1: #c07840; --base2: #884858; }
.scene-chats .chat-item:nth-child(10n + 7) .chat-avatar { --blob1: #b0a0e8; --blob2: #78d0b0; --blob3: #f0c0a0; --base1: #6860a8; --base2: #3a8870; }
.scene-chats .chat-item:nth-child(10n + 8) .chat-avatar { --blob1: #f0c0a8; --blob2: #a878d0; --blob3: #70b8e0; --base1: #c89070; --base2: #6848a0; }
.scene-chats .chat-item:nth-child(10n + 9) .chat-avatar { --blob1: #98d0f0; --blob2: #f098b0; --blob3: #c8e8a0; --base1: #4898b8; --base2: #b06078; }
.scene-chats .chat-item:nth-child(10n + 10) .chat-avatar { --blob1: #d0b878; --blob2: #78c8a0; --blob3: #e89070; --base1: #8a7840; --base2: #3a8860; }

.profile-meta-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--phone-muted);
  margin-top: 4px;
  width: 100%;
  flex-wrap: wrap;
}

.profile-meta-line .meta-dot {
  color: var(--phone-muted);
  font-weight: 700;
  line-height: 1;
}

.profile-status {
  font-size: 0.8rem;
  color: var(--tg-blue);
  margin-top: 4px;
}

.settings-list {
  padding: 4px 0 8px;
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  font-size: 0.88rem;
  border-bottom: 1px solid #f0f0f0;
  min-height: 44px;
}

.settings-icon-wrap {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-icon-wrap svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
  stroke-width: 2;
}

.icon-blue { background: #5AC8FA; }
.icon-orange { background: #FF9500; }
.icon-gray { background: #8E8E93; }
.icon-green { background: #34C759; }
.icon-purple { background: #AF52DE; }
.icon-pink { background: #FF2D55; }
.icon-teal { background: #32ADE6; }
.icon-indigo { background: #5856D6; }
.icon-yellow { background: #FFCC00; }
.icon-red { background: #FF3B30; }

.settings-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.settings-label {
  font-size: 0.9rem;
  color: var(--phone-text);
}

.settings-value {
  font-size: 0.78rem;
  color: var(--phone-muted);
}

.settings-value.clear {
  filter: none;
}

.settings-item > span:not(.settings-icon-wrap):not(.chevron):not(.settings-text) {
  flex: 1;
}

.settings-item .chevron {
  margin-left: auto;
  color: #c7c7cc;
  display: flex;
  align-items: center;
}

.settings-item .chevron svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.phone-frame.playing .phone-screen {
  box-shadow: inset 0 0 0 1px rgba(42, 171, 238, 0.15);
}

@media (max-width: 900px) {
  :root {
    --mobile-header-h: calc(4.5rem + env(safe-area-inset-top, 0px));
    --mobile-phone-gutter: 4px;
    --mobile-frame-pad: 8px;
    /* Высота — на весь экран под шапку; ширина от неё + почти края viewport */
    --mobile-phone-max-h: calc(100svh - var(--mobile-header-h) - 0.35rem);
    --mobile-phone-ar: 9 / 18;
  }

  html,
  body {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100dvh;
  }

  .app {
    height: auto;
    min-height: 100dvh;
    max-height: none;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .header {
    flex-shrink: 0;
    padding: max(0.65rem, env(safe-area-inset-top, 0)) 1rem 0.35rem;
  }

  .header h1 {
    font-size: 1.1rem;
  }

  .main {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding: 0.25rem 0 1.25rem;
    overflow: visible;
    min-height: auto;
  }

  /* Первый экран — телефон на всю высоту, форма ниже по скроллу */
  .phone-stage {
    order: -1;
    flex: 0 0 auto;
    width: 100%;
    min-height: calc(100svh - var(--mobile-header-h));
    height: auto;
    max-height: none;
    padding: 0.25rem var(--mobile-phone-gutter) 0.5rem;
    margin: 0;
    overflow: visible;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .phone-frame {
    width: min(
      calc(100vw - 2 * var(--mobile-phone-gutter)),
      calc(var(--mobile-phone-max-h) * 9 / 18)
    );
    max-width: calc(100vw - 2 * var(--mobile-phone-gutter));
    max-height: var(--mobile-phone-max-h);
    aspect-ratio: var(--mobile-phone-ar);
    height: auto;
    margin: 0 auto;
    padding: var(--mobile-frame-pad);
    border-radius: 40px;
    overflow: hidden;
    box-sizing: border-box;
    flex-shrink: 0;
    box-shadow:
      0 0 0 2px #333,
      0 0 0 4px #1a1a1a,
      0 25px 80px rgba(0, 0, 0, 0.6),
      inset 0 0 20px rgba(255, 255, 255, 0.03);
  }

  .phone-frame:has(.scene-home.active) .phone-home-indicator {
    bottom: 18px;
  }

  .setup-panel {
    order: 1;
    flex: 0 0 auto;
    max-height: none;
    margin: 0 0.5rem;
  }
}

@media (max-width: 480px) {
  :root {
    --mobile-header-h: calc(4.15rem + env(safe-area-inset-top, 0px));
    --mobile-phone-gutter: 3px;
    --mobile-frame-pad: 7px;
    --mobile-phone-ar: 9 / 17.85;
  }

  .header h1 {
    font-size: 1rem;
  }

  .subtitle {
    font-size: 0.72rem;
  }

  .by-sourness {
    font-size: 1.2rem;
  }

  .main {
    padding: 0.2rem 0 1.25rem;
    gap: 0.85rem;
  }

  .phone-stage {
    padding: 0.15rem var(--mobile-phone-gutter) 0.35rem;
  }

  .phone-frame {
    width: min(
      calc(100vw - 2 * var(--mobile-phone-gutter)),
      calc(var(--mobile-phone-max-h) * 9 / 17.85)
    );
    border-radius: 38px;
  }

  .phone-screen {
    border-radius: 30px;
  }

  .setup-panel {
    margin: 0 0.45rem;
    padding: 1rem;
    border-radius: 10px;
  }

  .setup-form input {
    font-size: 16px; /* без зума при фокусе на iOS */
  }
}

@media (min-width: 1400px) {
  .phone-frame {
    width: 340px;
    max-height: 85dvh;
  }
}
