/* ═══════════════════════════════════════════════════════════
   MEROJ KUKANOV — portfolio
   Design system inspired by splbrn.ru
   ═══════════════════════════════════════════════════════════ */

/* ─── Токены ─── */
:root {
  color-scheme: light;
  color: #323232;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  --page: #f2f3f4;
  --surface: #ffffff;
  --surface-subtle: #f2f2f8;
  --text-primary: #323232;
  --text-secondary: #727272;
  --text-tertiary: #a9a9a9;
  --text-link: #4969ed;

  --primary: #4969ed;
  --primary-hover: #304dd2;
  --secondary: #edf6ff;
  --secondary-hover: #deeeff;
  --secondary-content: #304dd2;
  --tertiary: #f2f3f4;

  /* Ширина макета — общая для колонок, подвала и кнопки «Наверх» */
  --layout-width: 978px;

  --toggle-bg: #ffffff;
  --toggle-hover: #f2f3f4;
  --toggle-border: #e6e6e6;

  /* Тонкие разделители внутри блоков */
  --border-subtle: #e6e6e6;

  --project-card-shadow: 0 18px 32px #26325829;

  --r-xl: 48px;
  --r-lg: 32px;
  --r-pill: 200px;
  --r-md: 16px;

  /* Отступ липкой левой колонки от верха страницы */
  --sticky-offset: 32px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  background: var(--page);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  color: #ffffff;
  --page: #121212;
  --surface: #202124;
  --surface-subtle: #323232;
  --text-primary: #ffffff;
  --text-secondary: #b7b7b7;
  --text-tertiary: #a9a9a9;
  --text-link: #9db3ff;
  --secondary: #243152;
  --secondary-hover: #30456f;
  --secondary-content: #d8e3f0;
  --tertiary: #323232;
  --toggle-bg: #323232;
  --toggle-hover: #4b4d55;
  --toggle-border: #4b4d55;
  --border-subtle: #34363a;
  --project-card-shadow: 0 18px 32px #00000061;
}

/* ─── Сброс ─── */
*, *::before, *::after { box-sizing: border-box; }

html {
  scrollbar-width: none;
  min-width: 320px;
  min-height: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
html::-webkit-scrollbar { display: none; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background-color: var(--page);
  color: var(--text-primary);
  transition: background-color 0.18s, color 0.18s;
  overflow-x: hidden;
}

button, a { font: inherit; }
button { border: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin: 0; }
svg { display: block; }

::selection { background: var(--primary); color: #fff; }

:focus-visible {
  outline: 3px solid #4969ed59;
  outline-offset: 3px;
  border-radius: 8px;
}

/* ─── Базовые интерактивные элементы ─── */
.pressable {
  transform-origin: 50%;
  transform: scale(1);
  transition: transform 0.1s, background-color 0.15s, color 0.15s, border-color 0.15s;
}
.pressable:active { transform: scale(0.96); }

.button {
  letter-spacing: -0.42px;
  white-space: nowrap;
  cursor: pointer;
  border-radius: var(--r-pill);
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  display: inline-flex;
  transition: transform 0.1s, background-color 0.15s, color 0.15s;
}
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-hover); }
.button-secondary { background: var(--secondary); color: var(--secondary-content); }
.button-secondary:hover { background: var(--secondary-hover); }
.button-tertiary { background: var(--tertiary); color: var(--text-primary); }
.button-tertiary:hover { background: var(--surface-subtle); }

.pdf-link {
  height: 28px;
  color: inherit;
  letter-spacing: -0.42px;
  cursor: pointer;
  background: none;
  align-items: center;
  gap: 8px;
  padding: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  display: inline-flex;
}
.pdf-link:hover { color: var(--text-link); }

.caption {
  color: var(--text-secondary);
  letter-spacing: -0.36px;
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
}

.tags { flex-wrap: wrap; gap: 4px; display: flex; }
.tag {
  background: var(--surface-subtle);
  letter-spacing: -0.42px;
  white-space: nowrap;
  border-radius: var(--r-pill);
  justify-content: center;
  align-items: center;
  min-height: 32px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  display: inline-flex;
}

/* ═══════════ ВКЛАДКИ: БЕЗ ЗАЛИВКИ, ИНДИКАТОР-ПОДЧЁРКИВАНИЕ ═══════════ */
.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex-wrap: wrap;
}

.tab {
  position: relative;
  cursor: pointer;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 12px;
  background: none;
  border: 0;
  color: var(--text-secondary);
  letter-spacing: -0.42px;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  display: inline-flex;
  transition: transform 0.1s, color 0.15s;
}
.tab:hover { color: var(--text-primary); }
.tab.is-active { color: var(--text-primary); font-weight: 600; }
.tab:focus-visible { outline: 3px solid #4969ed59; outline-offset: 2px; border-radius: var(--r-md); }

/* Активная вкладка помечена тонкой линией снизу — без фоновой заливки */
.tab::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--text-primary);
  scale: 0 1;
  transform-origin: center;
  transition: scale 0.22s var(--ease-out);
}
.tab.is-active::after { scale: 1 1; }
.tab.is-active:hover { color: var(--text-primary); }

/* ═══════════ МАКЕТ ═══════════ */
.portfolio-layout {
  display: grid;
  grid-template-columns: 360px 594px;
  align-items: start;
  gap: 24px;
  width: var(--layout-width);
  margin: 0 auto;
  padding: 32px 0;
}

/* ═══════════ ЛЕВАЯ КОЛОНКА ═══════════ */
.profile-column {
  display: flex;
  flex-direction: column;
  align-self: start;
  width: 360px;
  position: sticky;
  top: var(--sticky-offset);
}
.profile-stack { display: flex; flex-direction: column; gap: 24px; width: 100%; }

/* Карточка профиля — как остальные блоки сайта */
.profile-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  padding: 24px;
  transition: background-color 0.18s;
}

/* ─── Шапка профиля ─── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}
.profile-header-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.profile-role {
  color: var(--text-secondary);
  letter-spacing: -0.42px;
  font-size: 13px;
  font-weight: 400;
  line-height: 18px;
}

/* ─── Карточка вкладок: вкладки выровнены по блоку, иконка темы — у правого края ─── */
/* Отступы такие же, как у остальных карточек, поэтому вкладки начинаются на одной линии с их текстом */
.profile-card-tabs {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
}
.profile-card-tabs .tabs { flex: 1; min-width: 0; }
.profile-card-tabs .theme-toggle { flex: none; width: 40px; height: 40px; padding: 9px; }

/* ─── Аватар с 3D-переворотом ─── */
.avatar {
  cursor: pointer;
  perspective: 700px;
  will-change: transform;
  background: none;
  border-radius: var(--r-lg);
  width: 88px;
  height: 88px;
  padding: 0;
  position: relative;
  animation: avatar-invitation 5s ease-in-out infinite;
}
@keyframes avatar-invitation {
  0%, 81%, 100% { transform: translate(0) rotate(0); }
  85% { transform: translate(-1px) rotate(-1deg); }
  89% { transform: translate(2px) rotate(1.5deg); }
  93% { transform: translate(-2px) rotate(-1.5deg); }
  97% { transform: translate(1px) rotate(0.75deg); }
}

.avatar-flipper {
  border-radius: inherit;
  transform-origin: 50%;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.55s var(--ease-out);
  display: block;
  position: relative;
}
.avatar-face {
  border-radius: inherit;
  backface-visibility: hidden;
  display: block;
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.avatar-front { transform: rotateY(0deg); }
.avatar-back { transform: rotateY(180deg); }
.avatar.is-flipped .avatar-flipper { transform: rotateY(180deg); }

.avatar-monogram {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(140deg, #6b86ff 0%, #4969ed 46%, #2f3fa8 100%);
  color: #fff;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -1px;
  line-height: 1;
}
/* Фото профиля на лицевой стороне аватара */
.avatar-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
}
.avatar-monogram-alt {
  background: linear-gradient(140deg, #1b1e2a 0%, #32363f 50%, #0f1116 100%);
  font-size: 26px;
  letter-spacing: 0.5px;
}
.avatar-face::after {
  content: "";
  background: radial-gradient(ellipse 70px 60px at 30% 20%, #ffffff2e 0%, #ffffff12 38%, transparent 78%);
  position: absolute;
  inset: 0;
}

/* ─── Переключатель темы ─── */
.theme-toggle {
  border: 1px solid var(--toggle-border);
  background: var(--toggle-bg);
  cursor: pointer;
  border-radius: var(--r-pill);
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  padding: 11px;
  flex: none;
  display: inline-flex;
  transition: background-color 0.18s, border-color 0.18s, transform 0.1s;
}
.theme-toggle:hover { background: var(--toggle-hover); }

.theme-toggle-icon {
  justify-content: center;
  align-items: center;
  width: 20px;
  height: 20px;
  display: inline-flex;
  position: relative;
}
.theme-toggle-icon svg {
  position: absolute;
  inset: 0;
  width: 20px;
  height: 20px;
  transition: transform 0.35s var(--ease-out), opacity 0.2s ease;
}
.icon-sun { opacity: 1; transform: rotate(0deg) scale(1); }
.icon-moon { opacity: 0; transform: rotate(-70deg) scale(0.6); }
[data-theme="dark"] .icon-sun { opacity: 0; transform: rotate(70deg) scale(0.6); }
[data-theme="dark"] .icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }

/* ─── Текстовый блок профиля ─── */
.profile-name {
  letter-spacing: -0.72px;
  font-size: 24px;
  font-weight: 600;
  line-height: 28px;
}

.profile-card > p:not(.caption) {
  letter-spacing: -0.42px;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

/* ─── Быстрые ссылки: ровномерно по всей ширине блока ─── */
.quick-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-evenly;
  gap: 10px 6px;
  width: 100%;
}
.quick-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: -0.42px;
  cursor: pointer;
}
.quick-link svg { width: 18px; height: 18px; flex: 0 0 18px; color: var(--text-tertiary); transition: color 0.15s ease; }
.quick-link:hover { color: var(--text-link); }
.quick-link:hover svg { color: var(--text-link); }

/* ─── Карточка контактов ─── */
.profile-card-contact { gap: 14px; }
.contact-main { width: 100%; }

/* ═══════════ КНОПКА «НАВЕРХ» ═══════════ */
/* У правого края правой колонки — он же правый край макета */
.scroll-top-button {
  z-index: 70;
  position: fixed;
  right: max(16px, calc((100vw - var(--layout-width)) / 2));
  bottom: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px 0 14px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-pill);
  box-shadow: 0 6px 22px #1212121a;
  color: var(--text-primary);
  letter-spacing: -0.42px;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.94);
  transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.18s,
              border-color 0.18s, box-shadow 0.18s;
}
.scroll-top-button.is-visible { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.scroll-top-button:hover {
  background: var(--page);
  box-shadow: 0 8px 26px #12121226;
}
[data-theme="dark"] .scroll-top-button { box-shadow: 0 6px 22px #00000059; }
[data-theme="dark"] .scroll-top-button:hover { box-shadow: 0 8px 26px #00000073; }
.scroll-top-icon { display: inline-flex; }
.scroll-top-icon svg { width: 18px; height: 18px; }
.scroll-top-label { white-space: nowrap; }

/* ═══════════ ПРАВАЯ КОЛОНКА ═══════════ */
.main-content { min-width: 0; display: grid; }
.portfolio-content {
  grid-area: 1 / 1;
  display: none;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}
.portfolio-content.is-active {
  display: flex;
  animation: panel-in 0.34s var(--ease-out) both;
}
.portfolio-content.is-hidden { display: none !important; }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════ КАРТОЧКИ ВКЛАДКИ «ОБО МНЕ» ═══════════ */
.panel-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  transition: background-color 0.18s;
}
.panel-title {
  letter-spacing: -0.54px;
  font-size: 20px;
  font-weight: 600;
  line-height: 26px;
}
.panel-text,
.panel-card > p:not(.caption) {
  letter-spacing: -0.42px;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  color: var(--text-primary);
}
.panel-text { display: flex; flex-direction: column; gap: 12px; margin-top: 2px; }
.panel-card > .tags { margin-top: 6px; }

/* ─── Подпись ─── */
.panel-card > p.signature {
  align-self: flex-end;
  margin-top: 4px;
  color: var(--text-tertiary);
  letter-spacing: -0.3px;
  font-size: 13px;
  line-height: 18px;
}

/* ─── Закрывающий призыв ─── */
.panel-cta { gap: 10px; }
.panel-cta > p:not(.caption) {
  color: var(--text-secondary);
}
.panel-cta > .button { align-self: flex-start; margin-top: 6px; }

/* ═══════════ КАРТОЧКИ ПРОЕКТОВ ═══════════ */
/* Обложка и инфоблок объединены в одну карточку */
.project-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  position: relative;
  transition: transform 0.26s var(--ease-out), filter 0.26s var(--ease-out);
}
.project-card.is-interactive { cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
  .project-card.is-interactive:hover {
    filter: drop-shadow(var(--project-card-shadow));
    transform: translateY(-6px) scale(1.01);
  }
}

.project-card-open {
  z-index: 2;
  cursor: pointer;
  background: none;
  border-radius: var(--r-xl);
  padding: 0;
  position: absolute;
  inset: 0;
}

.project-media-frame {
  background: var(--surface-subtle);
  flex: none;
  width: 100%;
  height: 385px;
  position: relative;
  overflow: hidden;
}

/* ─── Обложки проектов (сгенерированный арт) ─── */
.project-art {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
/* ─── Космос: звёздное поле на двух слоях с дрейфом и мерцанием ─── */
.art-grid {
  position: absolute;
  inset: -20%;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 22px 44px, #ffffff 55%, transparent 56%),
    radial-gradient(1px 1px at 118px 26px, #ffffffcc 55%, transparent 56%),
    radial-gradient(1.2px 1.2px at 74px 132px, #ffffffb3 55%, transparent 56%);
  background-size: 170px 150px, 140px 190px, 210px 170px;
  animation: cosmos-drift 140s linear infinite;
}
.art-grid::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 60px 90px, #cfe4ff 55%, transparent 56%),
    radial-gradient(1.7px 1.7px at 190px 40px, #ffe6c2 55%, transparent 56%),
    radial-gradient(1.2px 1.2px at 132px 210px, #ffffff 55%, transparent 56%);
  background-size: 240px 220px, 310px 260px, 180px 250px;
  animation: cosmos-twinkle 7s ease-in-out infinite;
}
@keyframes cosmos-drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-170px, -150px, 0); }
}
@keyframes cosmos-twinkle {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 0.35; }
}
.art-wordmark {
  position: relative;
  z-index: 1;
  font-size: clamp(28px, 6vw, 46px);
  font-weight: 600;
  letter-spacing: -1.6px;
  color: #fff;
  text-align: center;
  padding: 0 24px;
  text-shadow: 0 2px 24px #00000038;
  transition: transform 0.4s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .project-card.is-interactive:hover .art-wordmark { transform: scale(1.04); }
}
.art-wordmark::after {
  content: "";
  display: block;
  height: 2px;
  width: 42px;
  margin: 14px auto 0;
  border-radius: 2px;
  background: #ffffff5c;
}

.art-quran {
  background:
    radial-gradient(ellipse 55% 45% at 78% 20%, #7b3fb8 0%, transparent 62%),
    radial-gradient(ellipse 60% 50% at 16% 84%, #1c6f8f 0%, transparent 60%),
    radial-gradient(ellipse 40% 35% at 34% 30%, #b0356f 0%, transparent 66%),
    radial-gradient(circle at 52% 118%, #2a1d5e 0%, transparent 62%),
    linear-gradient(158deg, #0d0b26 0%, #090919 52%, #04040c 100%);
  animation: cosmos-nebula 26s ease-in-out infinite alternate;
}
/* Падающая звезда */
.art-quran::after {
  content: "";
  position: absolute;
  z-index: 1;
  top: 14%;
  left: -25%;
  width: 130px;
  height: 2px;
  border-radius: 2px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, #ffffffe6 88%, #fff 100%);
  filter: drop-shadow(0 0 6px #ffffffb3);
  transform: rotate(21deg);
  animation: cosmos-shooting 9s ease-in 2s infinite;
}
@keyframes cosmos-nebula {
  from { background-position: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0 0; }
  to   { background-position: 8% 5%, -6% -4%, 5% -7%, 0% -5%, 0 0; }
}
@keyframes cosmos-shooting {
  0%, 68%   { transform: translate(0, 0) rotate(21deg); opacity: 0; }
  70%       { opacity: 1; }
  80%       { transform: translate(560px, 210px) rotate(21deg); opacity: 0; }
  100%      { transform: translate(560px, 210px) rotate(21deg); opacity: 0; }
}

/* ─── Внутри обложки вкладки — лого в левом верхнем углу, смартфон по центру ─── */
.project-media-frame .art-wordmark {
  position: absolute;
  z-index: 1;
  top: 22px;
  left: 24px;
  font-size: 20px;
  letter-spacing: -0.6px;
  text-align: left;
  padding: 0;
}
.project-media-frame .art-wordmark::after { margin: 10px 0 0; width: 30px; }

/* ─── Смартфон со скриншотом приложения ─── */
.phone {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: 191px;
  padding: 9px;
  border-radius: 32px;
  background: linear-gradient(160deg, #3b4048 0%, #15181d 38%, #0c0e12 100%);
  box-shadow:
    0 24px 48px #0000004d,
    0 2px 6px #00000033,
    inset 0 0 0 1px #ffffff2b;
  transition: transform 0.4s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .project-card.is-interactive:hover .phone { transform: translateX(-50%) translateY(-4px); }
}
.phone-screen {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  aspect-ratio: 408 / 757;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px #00000026;
}
.phone-screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.project-details {
  background: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 76px;
  padding: 16px 16px 16px 24px;
  transition: background-color 0.18s;
}
.project-copy { flex: auto; min-width: 0; }
.project-copy h2 {
  letter-spacing: -0.48px;
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
}
.project-copy p {
  letter-spacing: -0.42px;
  white-space: normal;
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}
.project-actions {
  z-index: 3;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

/* ═══════════ ПОДВАЛ ═══════════ */
.site-footer {
  width: var(--layout-width);
  margin: 0 auto;
  padding: 20px 0 32px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
}
.site-footer p {
  color: var(--text-tertiary);
  letter-spacing: -0.36px;
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
}

/* ═══════════ ОКНО КОНТАКТОВ ═══════════ */
.contact-window {
  z-index: 100;
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}
.contact-window[hidden] { display: none; }
.contact-window-backdrop {
  position: absolute;
  inset: 0;
  background: #00000040;
  opacity: 0;
  transition: opacity 0.22s ease-out;
  pointer-events: auto;
  backdrop-filter: blur(2px);
}
.contact-window.is-open .contact-window-backdrop { opacity: 1; }

.contact-sheet {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  padding: 24px 24px 20px;
  box-shadow: 0 -20px 48px #1212121f;
  transform: translateY(100%);
  transition: transform 0.28s var(--ease-out);
  pointer-events: auto;
  max-height: 100dvh;
  overflow-y: auto;
}
.contact-window.is-open .contact-sheet { transform: translateY(0); }

.contact-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.contact-sheet-header h2 {
  color: var(--text-primary);
  letter-spacing: -0.54px;
  font-size: 18px;
  font-weight: 600;
  line-height: 24px;
}
.contact-links { display: flex; flex-direction: column; gap: 8px; }
.contact-links .button { width: 100%; }

/* ═══════════ ПРОСМОТР ПРОЕКТА ═══════════ */
.viewer-backdrop {
  z-index: 90;
  position: fixed;
  inset: 0;
  background: #00000052;
  opacity: 0;
  transition: opacity 0.22s ease-out;
  backdrop-filter: blur(3px);
}
.viewer-backdrop[hidden] { display: none; }
.viewer-backdrop.is-open { opacity: 1; }

/* Модальное окно по центру: шапка и действия закреплены, середина прокручивается */
.project-viewer {
  z-index: 100;
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(660px, 100%);
  max-height: min(780px, calc(100dvh - 64px));
  transform: translate(-50%, -50%);
  background: var(--surface);
  border-radius: var(--r-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px #12121240;
}
[data-theme="dark"] .project-viewer { box-shadow: 0 24px 64px #000000a6; }
.project-viewer[hidden] { display: none; }
.project-viewer.is-opening { animation: viewer-enter 0.24s var(--ease-out) both; }
.project-viewer.is-closing { pointer-events: none; animation: viewer-exit 0.18s ease-in both; }
@keyframes viewer-enter {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 14px)) scale(0.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes viewer-exit {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to   { opacity: 0; transform: translate(-50%, calc(-50% + 8px)) scale(0.98); }
}

/* ─── Шапка ─── */
.viewer-header {
  z-index: 2;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 20px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
}
.viewer-heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.viewer-heading h2 {
  letter-spacing: -0.54px;
  font-size: 20px;
  font-weight: 600;
  line-height: 26px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.viewer-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--r-pill);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.18s, color 0.18s;
}
.viewer-close:hover { background: var(--tertiary); color: var(--text-primary); }

/* ─── Прокручиваемая часть ─── */
.viewer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
}
.viewer-body::-webkit-scrollbar { width: 8px; }
.viewer-body::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: var(--r-pill);
  border: 2px solid var(--surface);
}

.viewer-hero { display: flex; flex-direction: column; gap: 14px; }
.viewer-art {
  aspect-ratio: 4 / 3;
  border-radius: var(--r-lg);
  flex: none;
  width: 100%;
  position: relative;
  overflow: hidden;
}
/* Запасной фон с нулевой специфичностью, чтобы не перебивать градиент .art-* */
:where(.viewer-art) { background: var(--surface-subtle); }

/* В модалке обложка повторяет карточку: лого в углу, смартфон по центру */
.viewer-art .art-wordmark {
  position: absolute;
  z-index: 1;
  top: 22px;
  left: 24px;
  font-size: 20px;
  letter-spacing: -0.6px;
  text-align: left;
  padding: 0;
}
.viewer-art .art-wordmark::after { margin: 10px 0 0; width: 30px; }
.viewer-art .phone { width: 228px; bottom: 24px; }

.viewer-subtitle,
.viewer-about {
  letter-spacing: -0.42px;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}
.viewer-subtitle {
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  line-height: 21px;
}
.viewer-about { color: var(--text-secondary); }

.viewer-tags-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}

/* ─── Действия ─── */
.viewer-actions {
  z-index: 2;
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border-subtle);
}
.viewer-actions .button { flex: 1 1 auto; }

/* ═══════════ УВЕДОМЛЕНИЕ ═══════════ */
.toast {
  z-index: 200;
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: var(--surface);
  color: var(--text-primary);
  border-radius: var(--r-pill);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: -0.42px;
  box-shadow: 0 8px 28px #12121226;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.24s var(--ease-out);
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ═══════════ ЗАКРЕПЛЁННЫЙ БЛОК КОНТАКТА (мобильный) ═══════════ */
.mobile-contact-bar { display: none; }

@media (max-width: 600px) {
  .mobile-contact-bar {
    z-index: 80;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: block;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--page);
    border-top: 1px solid #1212120f;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }
  [data-theme="dark"] .mobile-contact-bar { border-top-color: #ffffff14; }
  .mobile-contact-bar .button { width: 100%; }
  .has-popup-viewer .mobile-contact-bar {
    opacity: 0;
    pointer-events: none;
    transform: translateY(100%);
  }
}

/* ═══════════ АДАПТИВНОСТЬ ═══════════ */
@media (max-width: 1023px) {
  :root { --layout-width: 654px; }
  .portfolio-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: min(var(--layout-width), 100%);
    padding: 24px 0;
  }
  .profile-column { width: 100%; position: static; }
  .profile-card { width: 100%; }
  .site-footer { width: min(var(--layout-width), 100%); padding-left: 24px; padding-right: 24px; }
}

@media (max-width: 600px) {
  :root { --layout-width: 100vw; }
  .portfolio-layout { width: 100%; padding: 0 0 16px; }
  .profile-card { border-radius: var(--r-xl); }
  .profile-stack { gap: 16px; }
  .project-card { border-radius: var(--r-lg); }
  .project-card-open { border-radius: var(--r-lg); }
  .project-media-frame { height: 300px; }
  /* Имя проекта и так есть под обложкой — на узком экране лого убираем */
  .project-media-frame .art-wordmark { display: none; }
  .phone { width: 150px; bottom: 16px; padding: 7px; border-radius: 26px; }
  .phone-screen { border-radius: 20px; }
  .site-footer { width: 100%; padding: 18px 24px 96px; }

  .project-details {
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 12px;
    min-height: 0;
    padding: 4px 16px 18px 20px;
  }
  .project-copy { flex: none; width: 100%; }
  .project-actions { width: 100%; }
  .project-actions .button { width: 100%; }

  .contact-window,
  .project-viewer {
    z-index: 100;
    position: fixed;
    inset: 0;
    height: 100dvh;
    min-height: 100dvh;
  }
  .contact-window { border-radius: 0; }

  /* Просмотр проекта — во весь экран, поэтому своя анимация без центрирования */
  .project-viewer {
    left: 0;
    top: 0;
    width: 100%;
    max-height: none;
    transform: none;
    border-radius: 0;
    box-shadow: none;
  }
  .project-viewer.is-opening { animation: viewer-enter-sheet 0.26s var(--ease-out) both; }
  .project-viewer.is-closing { animation: viewer-exit-sheet 0.2s ease-in both; }
  @keyframes viewer-enter-sheet {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @keyframes viewer-exit-sheet {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(12px); }
  }
  .viewer-header { padding: 14px 14px 14px 20px; }
  .viewer-heading h2 { font-size: 18px; line-height: 24px; }
  .viewer-body { padding: 20px; gap: 18px; }
  .viewer-art { aspect-ratio: 4 / 3; }
  .viewer-art .art-wordmark { top: 16px; left: 18px; font-size: 17px; }
  .viewer-art .phone { width: 132px; bottom: 14px; padding: 6px; border-radius: 22px; }
  .viewer-art .phone-screen { border-radius: 17px; }
  .viewer-actions {
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  }

  /* Верхние углы панели связи остаются скруглёнными */
  .contact-sheet {
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  }

  /* Кнопка «Наверх» — простая стрелка по правому краю, над панелью контакта */
  .scroll-top-button {
    right: 16px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
    padding: 0;
    gap: 0;
    border-radius: 50%;
    transform: translateY(10px) scale(0.9);
  }
  .scroll-top-button.is-visible { transform: translateY(0) scale(1); }
  .scroll-top-button.is-visible:active { transform: translateY(0) scale(0.94); }
  .scroll-top-label { display: none; }
  .has-popup-viewer .scroll-top-button { opacity: 0; pointer-events: none; }

  /* Уведомление — выше закреплённой панели контакта */
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }

  /* Кнопка «Связаться» переезжает в закреплённый нижний блок */
  .profile-card-contact .contact-main { display: none; }
}

@media (max-width: 400px) {
  .quick-links { gap: 10px 4px; }
  .project-actions .button { flex: 1 1 auto; }
  .panel-card { padding-left: 16px; padding-right: 16px; }
  .viewer-actions .button { flex: 1 1 100%; }
  .tab { padding: 8px 10px; }
}

@media (max-width: 340px) {
  .project-actions { flex-wrap: wrap; }
  .profile-header { gap: 12px; }
  .tab { padding: 8px 8px; }
  /* На очень узких экранах ссылки не влезают в один ряд — ровная сетка 2×2 */
  .quick-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-items: center;
    gap: 8px 4px;
  }
}

/* ═══════════ ДОСТУПНОСТЬ ═══════════ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .avatar { animation: none; }
  /* Падающая звезда скрывается через display — переход по opacity её подхватывает */
  .art-quran::after { animation: none; display: none; }
  .art-grid, .art-grid::before { animation: none; }
}