:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07080c;
  --card: rgba(18, 19, 26, 0.72);
  --card-gradient-a: rgba(255, 255, 255, 0.06);
  --card-gradient-b: rgba(255, 255, 255, 0.02);
  --stroke: rgba(243, 201, 138, 0.22);
  --text: #f6f1e8;
  --muted: #a39b8f;
  --hint: #7d766c;
  --gold: #e2b57a;
  --gold-2: #c4843a;
  --row: rgba(255, 255, 255, 0.04);
  --row-hover: rgba(255, 255, 255, 0.08);
  --row-border: rgba(255, 255, 255, 0.05);
  --row-border-hover: rgba(226, 181, 122, 0.28);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  --radius: 28px;
  --avatar-bg: radial-gradient(circle at 30% 25%, #2a2c36, #121318 70%);
  --avatar-shadow: 0 0 0 6px rgba(226, 181, 122, 0.08), 0 12px 30px rgba(0, 0, 0, 0.35);
  --icon-neutral-bg: rgba(255, 255, 255, 0.04);
  --action-bg: rgba(255, 255, 255, 0.06);
  --action-border: rgba(255, 255, 255, 0.08);
  --card-shine-color: rgba(255, 255, 255, 0.16);
  --card-border-gradient: linear-gradient(135deg, rgba(226, 181, 122, 0.7), transparent 38%, transparent 62%, rgba(92, 184, 196, 0.35));
  --orb-a-color: #5a3a18;
  --orb-b-color: #1c3d4a;
  --orb-c-color: #3a2458;
  --grain-opacity: 0.18;
  --toggle-bg: rgba(18, 19, 26, 0.82);
  --toggle-border: rgba(243, 201, 138, 0.28);
  --toggle-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --toast-bg: rgba(18, 19, 26, 0.92);
  --toast-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  --footer-fade: rgba(7, 8, 12, 0.55);
  --save-text: #1a130c;
  --save-shadow: 0 10px 24px rgba(196, 132, 58, 0.28);
  --home-icon: #d8c4a0;
  --phone-icon: #9be7c4;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f0e8;
  --card: rgba(255, 255, 255, 0.86);
  --card-gradient-a: rgba(255, 255, 255, 0.95);
  --card-gradient-b: rgba(255, 255, 255, 0.72);
  --stroke: rgba(196, 132, 58, 0.28);
  --text: #1a130c;
  --muted: #6b6358;
  --hint: #8a8175;
  --gold: #b8842f;
  --gold-2: #9a6824;
  --row: rgba(26, 19, 12, 0.04);
  --row-hover: rgba(26, 19, 12, 0.07);
  --row-border: rgba(26, 19, 12, 0.07);
  --row-border-hover: rgba(196, 132, 58, 0.35);
  --shadow: 0 24px 60px rgba(26, 19, 12, 0.1);
  --avatar-bg: radial-gradient(circle at 30% 25%, #fff8ee, #ece4d6 70%);
  --avatar-shadow: 0 0 0 6px rgba(196, 132, 58, 0.1), 0 12px 24px rgba(26, 19, 12, 0.08);
  --icon-neutral-bg: rgba(26, 19, 12, 0.04);
  --action-bg: rgba(26, 19, 12, 0.04);
  --action-border: rgba(26, 19, 12, 0.08);
  --card-shine-color: rgba(255, 255, 255, 0.55);
  --card-border-gradient: linear-gradient(135deg, rgba(196, 132, 58, 0.45), transparent 38%, transparent 62%, rgba(92, 184, 196, 0.2));
  --orb-a-color: #f0dcc0;
  --orb-b-color: #d4e8ef;
  --orb-c-color: #e8dff5;
  --grain-opacity: 0.07;
  --toggle-bg: rgba(255, 255, 255, 0.88);
  --toggle-border: rgba(196, 132, 58, 0.25);
  --toggle-shadow: 0 10px 24px rgba(26, 19, 12, 0.08);
  --toast-bg: rgba(255, 255, 255, 0.96);
  --toast-shadow: 0 16px 40px rgba(26, 19, 12, 0.12);
  --footer-fade: rgba(244, 240, 232, 0.72);
  --save-text: #1a130c;
  --save-shadow: 0 10px 24px rgba(196, 132, 58, 0.22);
  --home-icon: #8f7350;
  --phone-icon: #2f8f62;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: Manrope, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  transition: background 0.25s ease, color 0.25s ease;
}

.theme-toggle {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 25;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--toggle-bg);
  border: 1px solid var(--toggle-border);
  color: var(--gold);
  box-shadow: var(--toggle-shadow);
  backdrop-filter: blur(14px);
  touch-action: manipulation;
  transition: transform 0.2s ease, background 0.25s ease, border-color 0.25s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  transform: translateY(-1px);
}

.theme-toggle:active {
  transform: scale(0.96);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

[data-theme="dark"] .theme-toggle .icon-moon,
[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun,
[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: drift 18s ease-in-out infinite;
}

.orb-a {
  width: 420px;
  height: 420px;
  background: var(--orb-a-color);
  top: -120px;
  left: -80px;
}

.orb-b {
  width: 360px;
  height: 360px;
  background: var(--orb-b-color);
  right: -90px;
  bottom: -80px;
  animation-delay: -6s;
}

.orb-c {
  width: 240px;
  height: 240px;
  background: var(--orb-c-color);
  left: 40%;
  top: 45%;
  animation-delay: -11s;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: var(--grain-opacity);
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.card-car {
  display: none;
  overflow: hidden;
  background: transparent;
  border: 0;
  pointer-events: none;
}

.card-car picture,
.card-car img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
}

.card {
  position: relative;
  background: linear-gradient(180deg, var(--card-gradient-a), var(--card-gradient-b)), var(--card);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  overflow: hidden;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  padding: 1px;
  background: var(--card-border-gradient);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

[data-theme="light"] .card-shine {
  mix-blend-mode: normal;
  opacity: 0.75;
}

.card-shine {
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle at var(--mx, 30%) var(--my, 12%), var(--card-shine-color), transparent 32%);
  pointer-events: none;
  mix-blend-mode: screen;
}

.card-layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

.identity {
  text-align: center;
}

.avatar {
  width: 92px;
  height: 92px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--avatar-bg);
  border: 1px solid rgba(226, 181, 122, 0.45);
  box-shadow: var(--avatar-shadow);
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

h1 {
  font-family: Unbounded, sans-serif;
  font-size: clamp(26px, 7vw, 32px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.role {
  margin-top: 8px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 600;
}

.department {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  max-width: 34ch;
  margin-inline: auto;
}

.bio {
  margin-top: 14px;
  color: var(--hint);
  font-size: 13px;
  line-height: 1.55;
  max-width: 36ch;
  margin-inline: auto;
}

.qr-block {
  display: none;
  margin-top: 22px;
  padding: 14px;
  border-radius: 18px;
  background: var(--row);
  border: 1px solid var(--row-border);
  text-align: center;
}

.qr-block img {
  display: block;
  width: 180px;
  height: 180px;
  margin: 0 auto 8px;
  border-radius: 10px;
  background: #f6f1e8;
}

.qr-caption {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.contacts {
  display: grid;
  gap: 10px;
}

.block {
  display: grid;
  gap: 10px;
}

.row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 68px;
  text-align: left;
  padding: 12px;
  border-radius: 18px;
  background: var(--row);
  border: 1px solid var(--row-border);
  touch-action: manipulation;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.row:hover,
.row:focus-within {
  background: var(--row-hover);
  border-color: var(--row-border-hover);
}

button.row:active {
  transform: scale(0.985);
}

.icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--icon-neutral-bg);
}

.icon svg {
  width: 22px;
  height: 22px;
}

.instagram .icon {
  color: #ffb199;
  background: linear-gradient(135deg, rgba(247, 119, 55, 0.2), rgba(217, 70, 239, 0.18));
}

.vk .icon {
  color: #8ec8ff;
  background: rgba(0, 119, 255, 0.16);
}

.telegram .icon {
  color: #7ed4ff;
  background: rgba(34, 158, 217, 0.16);
}

.work .icon {
  color: var(--gold);
  background: rgba(226, 181, 122, 0.12);
}

.home .icon {
  color: var(--home-icon);
  background: var(--icon-neutral-bg);
}

.phone .icon {
  color: var(--phone-icon);
  background: rgba(52, 168, 116, 0.14);
}

.phone.row:hover,
.phone.row:focus-visible,
.phone.row:active,
.work.row:hover,
.work.row:focus-visible,
.work.row:active,
.home.row:hover,
.home.row:focus-visible,
.home.row:active {
  transform: none;
  background: var(--row);
  border-color: var(--row-border);
}

.meta {
  display: grid;
  min-width: 0;
}

.label {
  font-size: 12px;
  color: var(--muted);
}

.value {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hidden-number {
  display: grid;
  gap: 1px;
}

.dots {
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.action-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--action-bg);
  border: 1px solid var(--action-border);
  touch-action: manipulation;
}

.copy-btn {
  color: var(--gold);
}

.copy-btn svg {
  width: 16px;
  height: 16px;
}

.copy-btn.copied {
  border-color: rgba(155, 231, 196, 0.45);
  background: rgba(52, 168, 116, 0.14);
  color: #9be7c4;
}

.open-btn {
  color: var(--muted);
}

.open-btn .go {
  font-size: 16px;
  line-height: 1;
}

.action-btn:active {
  transform: scale(0.94);
}

.hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--hint);
}

.hint-desktop {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--toast-bg);
  border: 1px solid rgba(226, 181, 122, 0.35);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--toast-shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.go {
  color: var(--muted);
  font-size: 16px;
}

.save {
  width: 100%;
  padding: 16px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: var(--save-text);
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: var(--save-shadow);
  touch-action: manipulation;
}

.save:hover,
.save:focus-visible {
  filter: brightness(1.06);
}

.save:active {
  transform: scale(0.985);
}

.footer-extra {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.ghost {
  flex: 1;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--action-bg);
  border: 1px solid var(--action-border);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  touch-action: manipulation;
}

.ghost:active {
  transform: scale(0.985);
}

@keyframes drift {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(30px, -24px) scale(1.08);
  }
}

/* Phone: full-screen card, large tap targets, button pinned to bottom */
@media (max-width: 879px) {
  .stage {
    place-items: stretch;
    padding: 0;
  }

  .card {
    width: 100%;
    min-height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .card-layout {
    min-height: 100dvh;
    padding: max(28px, env(safe-area-inset-top)) 18px 18px;
  }

  .identity {
    margin-bottom: 22px;
  }

  .contacts {
    flex: 1;
  }

  .footer {
    position: sticky;
    bottom: 0;
    margin-top: 16px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: linear-gradient(180deg, transparent, var(--footer-fade) 28%);
  }

  .phone.row,
  .work.row,
  .home.row {
    grid-template-columns: 44px minmax(0, 1fr) auto;
  }

  .row-actions {
    display: flex;
    flex-shrink: 0;
    gap: 10px;
  }

  .row-actions .action-btn {
    width: 40px;
    height: 40px;
  }

  .card-car {
    display: block;
    margin-top: 8px;
    height: 210px;
  }
}

/* PC: landscape visiting card, two columns */
@media (min-width: 880px) {
  .stage {
    place-items: center;
    padding: 48px 32px;
    perspective: 1400px;
  }

  .card {
    width: min(1040px, 94vw);
    border-radius: 32px;
    transform-style: preserve-3d;
  }

  .card-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    grid-template-areas:
      "identity contacts"
      "footer contacts";
    gap: 18px 56px;
    padding: 48px 44px;
    align-items: start;
  }

  .identity {
    grid-area: identity;
    text-align: left;
  }

  .contacts {
    grid-area: contacts;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "ig vk"
      "tg phone"
      "work work"
      "home home"
      "car car";
    gap: 12px;
    position: relative;
    padding-left: 44px;
  }

  .instagram { grid-area: ig; }
  .vk { grid-area: vk; }
  .telegram { grid-area: tg; }
  .phone { grid-area: phone; }
  .work { grid-area: work; }
  .home { grid-area: home; }
  .card-car { grid-area: car; }

  .card-car {
    display: block;
    height: 280px;
    margin-top: 4px;
  }

  .contacts::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 1px;
    background: linear-gradient(180deg, transparent, rgba(226, 181, 122, 0.45), transparent);
  }

  .block {
    display: contents;
  }

  .footer {
    grid-area: footer;
    align-self: end;
  }

  .avatar {
    width: 112px;
    height: 112px;
    margin: 0 0 22px;
  }

  h1 {
    font-size: 40px;
  }

  .role {
    font-size: 16px;
  }

  .department,
  .bio {
    margin-inline: 0;
    max-width: none;
    text-align: left;
  }

  .department {
    font-size: 14px;
  }

  .bio {
    font-size: 14px;
    max-width: 30ch;
  }

  .qr-block {
    display: block;
    width: fit-content;
  }

  .row {
    min-height: 76px;
    padding: 14px;
  }

  .work .value,
  .home .value {
    overflow: visible;
    text-overflow: unset;
  }

  button.row:hover,
  button.row:focus-visible {
    transform: translateY(-2px);
  }

  .hint-phone {
    display: none;
  }

  .hint-desktop {
    display: block;
  }

  .save {
    width: auto;
    min-width: 220px;
    padding: 14px 22px;
  }

  .footer-extra {
    max-width: 220px;
    flex-direction: column;
  }
}

@media (min-width: 880px) and (max-width: 1100px) {
  .card-layout {
    grid-template-columns: 280px 1fr;
    gap: 16px 36px;
    padding: 36px 32px;
  }

  .contacts {
    padding-left: 32px;
  }

  h1 {
    font-size: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb,
  .row,
  .save {
    animation: none;
    transition: none;
  }
}
