/* ==========================================================================
   Визитка — card site styles
   1. Tokens & reset        5. Editor               9. Sheet / overlay
   2. Themes                6. Fields              10. Toast
   3. Ambient background    7. Theme picker        11. Motion & responsive
   4. Card (view mode)      8. Link rows
   ========================================================================== */

/* 1. Tokens & reset ------------------------------------------------------- */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --r-xl: 30px;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --shell: 1060px;
  --card-w: 520px;
  --tap: 44px;
  font-synthesis-weight: none;
  -webkit-text-size-adjust: 100%;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

html {
  background: var(--bg);
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 700px at 8% -12%, var(--glow-1), transparent 62%),
    radial-gradient(900px 640px at 102% 4%, var(--glow-2), transparent 58%),
    linear-gradient(178deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.4s var(--ease), color 0.3s var(--ease);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

svg {
  display: block;
}

a {
  color: inherit;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 2. Themes --------------------------------------------------------------- */
[data-theme="dark_neon"] {
  --bg: #06070f;
  --bg-2: #0a0d1c;
  --ink: #f3f5ff;
  --muted: #99a3c2;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.09);
  --panel: rgba(13, 16, 32, 0.86);
  --line: rgba(255, 255, 255, 0.1);
  --field: rgba(255, 255, 255, 0.045);
  --accent: #7c5cff;
  --accent-2: #1fe0c0;
  --on-accent: #ffffff;
  --glow-1: rgba(124, 92, 255, 0.45);
  --glow-2: rgba(31, 224, 192, 0.26);
  --shadow: 0 34px 90px -30px rgba(0, 0, 0, 0.85);
  --sheen: rgba(255, 255, 255, 0.13);
  --ok: #38e0a5;
  --warn: #ffb35c;
  --err: #ff6b81;
  color-scheme: dark;
}

[data-theme="cyberpunk"] {
  --bg: #0a0410;
  --bg-2: #150722;
  --ink: #fff2fb;
  --muted: #c49bbd;
  --surface: rgba(255, 45, 149, 0.075);
  --surface-2: rgba(255, 45, 149, 0.14);
  --panel: rgba(24, 6, 30, 0.88);
  --line: rgba(255, 45, 149, 0.28);
  --field: rgba(255, 45, 149, 0.07);
  --accent: #ff2d95;
  --accent-2: #ffd166;
  --on-accent: #1a0010;
  --glow-1: rgba(255, 45, 149, 0.42);
  --glow-2: rgba(0, 229, 255, 0.22);
  --shadow: 0 34px 90px -30px rgba(0, 0, 0, 0.9);
  --sheen: rgba(255, 255, 255, 0.16);
  --ok: #6ef3c5;
  --warn: #ffd166;
  --err: #ff5f7d;
  color-scheme: dark;
}

[data-theme="minimal_dark"] {
  --bg: #0b0c0e;
  --bg-2: #111216;
  --ink: #f2f3f5;
  --muted: #8d909a;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --panel: rgba(17, 18, 22, 0.9);
  --line: rgba(255, 255, 255, 0.09);
  --field: rgba(255, 255, 255, 0.035);
  --accent: #e9ebf0;
  --accent-2: #b9bec9;
  --on-accent: #0b0c0e;
  --glow-1: rgba(255, 255, 255, 0.07);
  --glow-2: rgba(255, 255, 255, 0.035);
  --shadow: 0 30px 80px -32px rgba(0, 0, 0, 0.9);
  --sheen: rgba(255, 255, 255, 0.1);
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #fb7185;
  color-scheme: dark;
}

[data-theme="sunset"] {
  --bg: #160a1d;
  --bg-2: #2b0f22;
  --ink: #fff2ec;
  --muted: #d6a9b1;
  --surface: rgba(255, 180, 140, 0.1);
  --surface-2: rgba(255, 180, 140, 0.16);
  --panel: rgba(40, 15, 34, 0.88);
  --line: rgba(255, 170, 120, 0.22);
  --field: rgba(255, 180, 140, 0.09);
  --accent: #ff7a59;
  --accent-2: #b06bff;
  --on-accent: #2a0c07;
  --glow-1: rgba(255, 122, 89, 0.42);
  --glow-2: rgba(176, 107, 255, 0.34);
  --shadow: 0 34px 90px -30px rgba(0, 0, 0, 0.85);
  --sheen: rgba(255, 255, 255, 0.16);
  --ok: #5ee6a8;
  --warn: #ffc46b;
  --err: #ff7a8a;
  color-scheme: dark;
}

[data-theme="ocean"] {
  --bg: #03101c;
  --bg-2: #04212f;
  --ink: #eaf9ff;
  --muted: #8fb6c8;
  --surface: rgba(90, 220, 255, 0.07);
  --surface-2: rgba(90, 220, 255, 0.13);
  --panel: rgba(5, 30, 44, 0.88);
  --line: rgba(120, 220, 255, 0.2);
  --field: rgba(90, 220, 255, 0.06);
  --accent: #22d3ee;
  --accent-2: #38bdf8;
  --on-accent: #03212b;
  --glow-1: rgba(34, 211, 238, 0.34);
  --glow-2: rgba(56, 189, 248, 0.26);
  --shadow: 0 34px 90px -30px rgba(0, 0, 0, 0.85);
  --sheen: rgba(255, 255, 255, 0.14);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #fb7185;
  color-scheme: dark;
}

[data-theme="paper"] {
  --bg: #f5f0e7;
  --bg-2: #e9e0d0;
  --ink: #211a13;
  --muted: #6f6252;
  --surface: rgba(255, 255, 255, 0.62);
  --surface-2: rgba(255, 255, 255, 0.88);
  --panel: rgba(252, 248, 241, 0.94);
  --line: rgba(33, 26, 19, 0.12);
  --field: rgba(255, 255, 255, 0.7);
  --accent: #b4552f;
  --accent-2: #1f6f5c;
  --on-accent: #fff8f1;
  --glow-1: rgba(255, 196, 140, 0.55);
  --glow-2: rgba(150, 200, 180, 0.38);
  --shadow: 0 26px 60px -28px rgba(80, 58, 36, 0.45);
  --sheen: rgba(255, 255, 255, 0.6);
  --ok: #157a52;
  --warn: #a2620b;
  --err: #b3352f;
  color-scheme: light;
}

[data-theme="aurora"] {
  --bg: #04120f;
  --bg-2: #07201d;
  --ink: #ecfff8;
  --muted: #93bdb1;
  --surface: rgba(88, 245, 176, 0.07);
  --surface-2: rgba(88, 245, 176, 0.13);
  --panel: rgba(6, 26, 23, 0.88);
  --line: rgba(120, 255, 206, 0.2);
  --field: rgba(88, 245, 176, 0.06);
  --accent: #58f5b0;
  --accent-2: #7c9cff;
  --on-accent: #04231a;
  --glow-1: rgba(88, 245, 176, 0.32);
  --glow-2: rgba(124, 156, 255, 0.3);
  --shadow: 0 34px 90px -30px rgba(0, 0, 0, 0.86);
  --sheen: rgba(255, 255, 255, 0.14);
  --ok: #58f5b0;
  --warn: #ffd479;
  --err: #ff7a8a;
  color-scheme: dark;
}

[data-theme="matrix"] {
  --bg: #020a04;
  --bg-2: #04150a;
  --ink: #d8ffe4;
  --muted: #71a883;
  --surface: rgba(57, 255, 136, 0.06);
  --surface-2: rgba(57, 255, 136, 0.12);
  --panel: rgba(3, 18, 9, 0.9);
  --line: rgba(57, 255, 136, 0.24);
  --field: rgba(57, 255, 136, 0.05);
  --accent: #39ff88;
  --accent-2: #0affc8;
  --on-accent: #01160a;
  --glow-1: rgba(57, 255, 136, 0.26);
  --glow-2: rgba(10, 255, 200, 0.16);
  --shadow: 0 34px 90px -30px rgba(0, 0, 0, 0.92);
  --sheen: rgba(200, 255, 220, 0.12);
  --ok: #39ff88;
  --warn: #d4ff5c;
  --err: #ff5f6d;
  color-scheme: dark;
}

[data-theme="candy"] {
  --bg: #fff3f9;
  --bg-2: #ffe8f4;
  --ink: #33112a;
  --muted: #8f5f7d;
  --surface: rgba(255, 255, 255, 0.66);
  --surface-2: rgba(255, 255, 255, 0.9);
  --panel: rgba(255, 250, 253, 0.94);
  --line: rgba(120, 40, 90, 0.12);
  --field: rgba(255, 255, 255, 0.78);
  --accent: #ff5fa2;
  --accent-2: #8b5cf6;
  --on-accent: #fff5fb;
  --glow-1: rgba(255, 140, 190, 0.55);
  --glow-2: rgba(160, 130, 255, 0.42);
  --shadow: 0 26px 60px -26px rgba(150, 60, 110, 0.4);
  --sheen: rgba(255, 255, 255, 0.7);
  --ok: #16875f;
  --warn: #a2620b;
  --err: #cf2f63;
  color-scheme: light;
}

[data-theme="noir"] {
  --bg: #000000;
  --bg-2: #0d0d0d;
  --ink: #f7f7f7;
  --muted: #9a9a9a;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.1);
  --panel: rgba(10, 10, 10, 0.92);
  --line: rgba(255, 255, 255, 0.14);
  --field: rgba(255, 255, 255, 0.04);
  --accent: #ffffff;
  --accent-2: #8c8c8c;
  --on-accent: #000000;
  --glow-1: rgba(255, 255, 255, 0.09);
  --glow-2: rgba(255, 255, 255, 0.05);
  --shadow: 0 34px 90px -30px rgba(0, 0, 0, 0.95);
  --sheen: rgba(255, 255, 255, 0.12);
  --ok: #f2f2f2;
  --warn: #c9c9c9;
  --err: #bdbdbd;
  color-scheme: dark;
}

/* 3. Ambient background --------------------------------------------------- */
.aura {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.aura__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  will-change: transform;
}

.aura__orb--1 {
  width: 46vmax;
  height: 46vmax;
  top: -18vmax;
  left: -14vmax;
  background: var(--glow-1);
  animation: drift 22s var(--ease) infinite alternate;
}

.aura__orb--2 {
  width: 38vmax;
  height: 38vmax;
  top: 24vmax;
  right: -18vmax;
  background: var(--glow-2);
  animation: drift 26s var(--ease) infinite alternate-reverse;
}

.aura__orb--3 {
  width: 30vmax;
  height: 30vmax;
  bottom: -16vmax;
  left: 22vmax;
  background: var(--glow-1);
  opacity: 0.32;
  animation: drift 30s var(--ease) infinite alternate;
}

.aura__noise {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  mix-blend-mode: overlay;
  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='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.root {
  position: relative;
  z-index: 1;
}

/* 4. Card (view mode) ----------------------------------------------------- */
.stage {
  width: 100%;
  max-width: var(--card-w);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 22px) 16px
    calc(env(safe-area-inset-bottom) + 40px);
}

/* Leave room for the floating “edit” pill so it never covers the card footer. */
.view--owner .stage {
  padding-bottom: calc(env(safe-area-inset-bottom) + 96px);
}

.card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 28px 20px 20px;
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow), inset 0 1px 0 var(--sheen);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
  animation: card-in 0.7s var(--ease) both;
}

.card::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -55% -25% auto;
  height: 78%;
  background: radial-gradient(58% 100% at 50% 0%, var(--accent) 0%, transparent 72%);
  opacity: 0.4;
  filter: blur(46px);
  pointer-events: none;
}

.card::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(160deg, var(--sheen), transparent 38%);
  opacity: 0.5;
  pointer-events: none;
}

.card__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.avatar {
  width: 94px;
  height: 94px;
  border-radius: 32px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  background: linear-gradient(145deg, var(--av1, #7c5cff), var(--av2, #1fe0c0));
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 20px 44px -18px var(--av1, #7c5cff),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  animation: avatar-in 0.8s var(--ease) both;
  position: relative;
}

.avatar::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 26px;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.24), transparent 46%);
  pointer-events: none;
}

/* Uploaded photo: the sheen layer still sits on top, so it reads as one object. */
.avatar--photo {
  padding: 0;
  overflow: hidden;
  background: var(--surface-2);
}

.avatar--photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Spinnable 3D gem (canvas painted by model3d.js). */
.avatar--3d {
  padding: 0;
  overflow: visible;
  background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--accent) 40%, transparent), transparent 70%),
    linear-gradient(150deg, var(--surface-2), var(--surface));
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.avatar--3d.is-dragging {
  cursor: grabbing;
}

.avatar__canvas {
  position: absolute;
  inset: 0;
  display: block;
}

.model3d {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.avatar--sm {
  width: 74px;
  height: 74px;
  border-radius: 24px;
  font-size: 25px;
  margin-bottom: 0;
}

.avatar--sm::after {
  border-radius: 19px;
  inset: 5px;
}

.card__name {
  font-size: clamp(25px, 6.6vw, 33px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.12;
  text-wrap: balance;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.card__handle {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.card__handle::before {
  content: "@";
  opacity: 0.6;
}

.card__bio {
  margin-top: 12px;
  max-width: 38ch;
  font-size: 14.5px;
  line-height: 1.58;
  color: var(--muted);
  text-wrap: pretty;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-top: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.chip svg {
  width: 13px;
  height: 13px;
  opacity: 0.85;
}

.links {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 22px;
}

.link-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 60px;
  padding: 9px 13px 9px 9px;
  border-radius: 18px;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: transform 0.22s var(--ease), border-color 0.22s var(--ease),
    box-shadow 0.22s var(--ease), background 0.22s var(--ease);
  animation: rise 0.55s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 55ms + 140ms);
  overflow: hidden;
}

.link-btn:hover {
  transform: translateY(-2px);
  border-color: var(--p, var(--accent));
  box-shadow: 0 16px 34px -20px var(--p, var(--accent));
}

.link-btn:active {
  transform: scale(0.982);
}

.link-btn:focus-visible {
  outline-offset: 3px;
}

.link-btn__icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: var(--p, var(--accent));
  background: var(--surface);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--p, var(--accent)) 14%, transparent);
  border-color: color-mix(in srgb, var(--p, var(--accent)) 26%, transparent);
}

.link-btn__icon svg {
  width: 21px;
  height: 21px;
}

/* A custom uploaded icon fills the whole 42px tile. */
.link-btn__icon--custom {
  padding: 0;
  overflow: hidden;
  border-color: var(--line);
  background: var(--surface);
}

.link-btn__icon--custom img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.link-btn__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.link-btn__title {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-btn__sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
}

.link-btn__arrow {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  opacity: 0.42;
  transition: transform 0.22s var(--ease), opacity 0.22s;
}

.link-btn:hover .link-btn__arrow {
  transform: translateX(3px);
  opacity: 0.8;
}

.card__foot {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  flex: 1 1 auto;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.ghost-btn:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.ghost-btn svg {
  width: 15px;
  height: 15px;
}

/* CTA under the card */
.cta {
  margin-top: 16px;
  padding: 22px 20px;
  border-radius: var(--r-lg);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  animation: rise 0.6s var(--ease) 0.3s both;
}

.cta__eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 7px;
}

.cta__title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.cta__text {
  margin: 7px auto 16px;
  max-width: 34ch;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  text-wrap: pretty;
}

/* Floating "edit" pill for the owner */
.float-edit {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid var(--sheen);
  box-shadow: 0 18px 40px -14px var(--accent), 0 0 0 1px rgba(0, 0, 0, 0.04);
  animation: pill-in 0.5s var(--ease) 0.4s both;
  white-space: nowrap;
}

.float-edit svg {
  width: 16px;
  height: 16px;
}

.float-edit:active {
  transform: translateX(-50%) scale(0.97);
}

/* Buttons ----------------------------------------------------------------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 14px;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  overflow: hidden;
  transition: transform 0.18s var(--ease), filter 0.18s, background 0.2s,
    border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.975);
}

.btn:disabled {
  opacity: 0.55;
  pointer-events: none;
}

.btn--primary {
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 14px 34px -16px var(--accent);
}

.btn--primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.24), transparent 56%);
  pointer-events: none;
}

.btn svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
}

.btn--ghost {
  color: var(--ink);
  background: var(--surface-2);
  border-color: var(--line);
}

.btn--ghost:hover {
  background: var(--surface);
}

.btn--dashed {
  width: 100%;
  min-height: 46px;
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--line);
}

.btn--dashed:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.btn--dashed svg {
  width: 16px;
  height: 16px;
}

.btn--sm {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 11px;
  font-size: 12.5px;
  gap: 6px;
}

.btn--sm svg {
  width: 14px;
  height: 14px;
}

.btn--block {
  width: 100%;
}

/* 5. Editor --------------------------------------------------------------- */
.editor {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid transparent;
}

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

.topbar__title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar__sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: background 0.2s, transform 0.15s;
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn--wide {
  width: auto;
  gap: 6px;
  padding: 0 13px;
  font-size: 12.5px;
  font-weight: 600;
}

.icon-btn--wide svg {
  width: 15px;
  height: 15px;
}

.layout {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 6px 16px 0;
  display: grid;
  gap: 14px;
  flex: 1 1 auto;
}

.form {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
}

.panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: inset 0 1px 0 var(--sheen);
  animation: rise 0.5s var(--ease) both;
}

.panel:nth-of-type(2) {
  animation-delay: 0.05s;
}

.panel:nth-of-type(3) {
  animation-delay: 0.1s;
}

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.panel__head h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.panel__head p {
  font-size: 11.5px;
  color: var(--muted);
  text-align: right;
  max-width: 52%;
}

.panel__note {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

/* 6. Fields --------------------------------------------------------------- */
.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.field__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field__count {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  opacity: 0.8;
}

.field__count.is-over {
  color: var(--err);
  opacity: 1;
}

.field__hint {
  min-height: 15px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.field__hint.is-ok {
  color: var(--ok);
}

.field__hint.is-bad {
  color: var(--err);
}

.field__hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--ink);
  opacity: 0.82;
}

.input {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border-radius: 13px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  font-size: 15px;
  letter-spacing: -0.005em;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  -webkit-appearance: none;
  appearance: none;
}

.input::placeholder {
  color: var(--muted);
  opacity: 0.62;
}

.input:hover {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
  background: var(--surface-2);
}

.input--area {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

.input--mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  letter-spacing: 0;
}

.input--invalid,
.input--invalid:focus {
  border-color: var(--err);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--err) 14%, transparent);
}

.select-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.select-wrap svg {
  position: absolute;
  right: 11px;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.55;
}

.input--select {
  padding-right: 32px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
}

.input option {
  background: var(--bg);
  color: var(--ink);
}

/* Avatar picker (initials / photo / 3D) */
.avatar-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 14px;
}

.avatar-edit__controls {
  display: grid;
  gap: 9px;
  min-width: 200px;
  flex: 1 1 200px;
}

.avatar-edit__actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.avatar-edit__actions .btn {
  white-space: nowrap;
}

.avatar-edit__note {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}

.segmented {
  display: flex;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  background: var(--field);
  border: 1px solid var(--line);
}

.segmented__item {
  flex: 1 1 0;
  padding: 7px 10px;
  text-align: center;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--muted);
  transition: color 0.18s, background 0.2s;
}

.segmented__item[aria-pressed="true"] {
  color: var(--on-accent);
  background: var(--accent);
}

/* Slug availability marker */
.slug-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.slug-state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.slug-state.is-checking::before {
  animation: blink 1s ease-in-out infinite;
}

/* 7. Theme picker --------------------------------------------------------- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.theme-tile {
  position: relative;
  padding: 0;
  overflow: hidden;
  border-radius: 14px;
  text-align: left;
  background: var(--field);
  border: 1px solid var(--line);
  transition: transform 0.18s var(--ease), border-color 0.2s, box-shadow 0.2s;
}

.theme-tile:active {
  transform: scale(0.975);
}

.theme-tile__swatch {
  display: block;
  height: 46px;
  border-bottom: 1px solid var(--line);
}

.theme-tile__label {
  display: block;
  padding: 7px 10px 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-tile__check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s, transform 0.24s var(--ease);
}

.theme-tile.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.theme-tile.is-active .theme-tile__check {
  opacity: 1;
  transform: scale(1);
}

/* 8. Link rows ------------------------------------------------------------ */
.links-editor {
  display: grid;
  gap: 9px;
}

.link-row {
  display: grid;
  gap: 8px;
  padding: 11px;
  border-radius: 16px;
  background: var(--field);
  border: 1px solid var(--line);
  animation: rise 0.32s var(--ease) both;
}

.link-row__top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-row__badge {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--p, var(--accent));
  background: var(--surface);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--p, var(--accent)) 14%, transparent);
  border-color: color-mix(in srgb, var(--p, var(--accent)) 26%, transparent);
}

.link-row__badge svg {
  width: 18px;
  height: 18px;
}

.link-row__slot {
  position: relative;
  flex: 0 0 auto;
  display: block;
}

.link-row__badge {
  padding: 0;
  overflow: hidden;
  transition: border-color 0.18s, transform 0.16s;
}

.link-row__badge:active {
  transform: scale(0.94);
}

.link-row__badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.link-row__badge-x {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  line-height: 1;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.link-row__tools {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}

.tool {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  font-size: 13px;
  line-height: 1;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
}

.tool:hover {
  color: var(--ink);
  background: var(--surface-2);
  border-color: var(--line);
}

.tool:disabled {
  opacity: 0.3;
  pointer-events: none;
}

.tool--danger:hover {
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 40%, transparent);
  background: color-mix(in srgb, var(--err) 12%, transparent);
}

.tool svg {
  width: 14px;
  height: 14px;
}

.panel__empty {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
  padding: 4px 0 2px;
}

.panel__empty[hidden] {
  display: none;
}

/* Save bar ---------------------------------------------------------------- */
.savebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 46%);
  pointer-events: none;
}

.savebar__inner {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 9px 9px 15px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.savebar__state {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.savebar__state b {
  color: var(--ink);
  font-weight: 600;
}

.savebar__state.is-bad {
  color: var(--err);
}

.savebar__state.is-ok {
  color: var(--ok);
}

.savebar .btn {
  flex: 0 0 auto;
  min-width: 138px;
}

/* 9. Preview -------------------------------------------------------------- */
.preview {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.preview__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.preview__close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.phone {
  border-radius: 36px;
  padding: 8px;
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  box-shadow: var(--shadow), inset 0 1px 0 var(--sheen);
}

.phone__notch {
  width: 74px;
  height: 4px;
  margin: 4px auto 8px;
  border-radius: 999px;
  background: var(--line);
}

.phone__screen {
  border-radius: 28px;
  overflow: hidden;
  background: var(--bg);
  max-height: min(66vh, 640px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.phone__screen::-webkit-scrollbar {
  display: none;
}

.phone__screen .card {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  padding: 22px 15px 18px;
  min-height: 100%;
  animation: none;
}

.phone__screen .card::before {
  inset: -60% -30% auto;
  height: 70%;
  opacity: 0.5;
}

.phone__screen .card::after {
  display: none;
}

.phone__screen .avatar {
  width: 74px;
  height: 74px;
  border-radius: 25px;
  font-size: 27px;
  margin-bottom: 11px;
}

.phone__screen .card__name {
  font-size: 23px;
}

.phone__screen .card__bio {
  font-size: 13px;
  margin-top: 9px;
}

.phone__screen .link-btn {
  min-height: 54px;
  animation-delay: calc(var(--i, 0) * 35ms);
}

.phone__screen .links {
  margin-top: 16px;
}

.preview__hint {
  font-size: 11.5px;
  text-align: center;
  color: var(--muted);
  opacity: 0.85;
}

.preview__empty {
  padding: 20px 12px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* 10. Sheet / overlay ----------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.overlay[hidden] {
  display: none;
}

.overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 4, 10, 0.58);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  animation: fade 0.3s ease both;
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 -30px 80px -20px rgba(0, 0, 0, 0.6);
  animation: sheet-in 0.42s var(--ease) both;
}

.sheet__grab {
  width: 40px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: var(--line);
}

.sheet__icon {
  width: 54px;
  height: 54px;
  margin: 4px auto 12px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 16px 36px -14px var(--accent);
}

.sheet__icon svg {
  width: 26px;
  height: 26px;
}

.sheet h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: center;
  text-wrap: balance;
}

.sheet__text {
  margin: 8px auto 18px;
  max-width: 32ch;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
  color: var(--muted);
  text-wrap: pretty;
}

.share-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--field);
  border: 1px dashed var(--line);
  margin-bottom: 14px;
}

.share-box code {
  flex: 1 1 auto;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.sheet__actions {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.sheet__stats {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 14px 0 4px;
}

.sheet__stat {
  text-align: center;
}

.sheet__stat b {
  display: block;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sheet__stat span {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* 11. Toast --------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 12px);
  z-index: 80;
  transform: translate(-50%, -16px);
  max-width: min(92vw, 420px);
  padding: 11px 16px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.35s var(--ease);
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-bad {
  border-color: color-mix(in srgb, var(--err) 55%, var(--line));
}

/* Boot skeleton ----------------------------------------------------------- */
.boot {
  position: relative;
  z-index: 1;
  padding: calc(env(safe-area-inset-top) + 34px) 16px;
  display: grid;
  place-items: start center;
  min-height: 100vh;
  min-height: 100dvh;
}

.boot__card {
  width: 100%;
  max-width: var(--card-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 20px;
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--line);
}

.sk {
  border-radius: 10px;
  background: linear-gradient(
    100deg,
    var(--surface) 20%,
    var(--surface-2) 42%,
    var(--surface) 62%
  );
  background-size: 220% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.sk--avatar {
  width: 94px;
  height: 94px;
  border-radius: 32px;
  margin-bottom: 8px;
}

.sk--line {
  height: 12px;
  border-radius: 999px;
}

.sk--chip {
  width: 120px;
  height: 24px;
  border-radius: 999px;
  margin-top: 4px;
}

.sk--btn {
  width: 100%;
  height: 60px;
  border-radius: 18px;
  margin-top: 4px;
}

.sk--btn:first-of-type {
  margin-top: 18px;
}

/* Dev badge --------------------------------------------------------------- */
.dev-badge {
  position: fixed;
  left: 12px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 90;
  pointer-events: none;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #1a1200;
  background: #ffd166;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.dev-badge[hidden] {
  display: none;
}

/* Fatal / empty states ---------------------------------------------------- */
.notice {
  width: 100%;
  max-width: var(--card-w);
  margin: 0 auto;
  padding: 26px 20px;
  border-radius: var(--r-xl);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  animation: rise 0.5s var(--ease) both;
}

.notice__icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.notice__icon svg {
  width: 26px;
  height: 26px;
}

.notice h1 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  text-wrap: balance;
}

.notice p {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 34ch;
  margin: 0 auto 18px;
  text-wrap: pretty;
}

.notice__actions {
  display: grid;
  gap: 8px;
}

/* 10b. Accounts (login / register) ---------------------------------------- */
.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: calc(env(safe-area-inset-top) + 26px) 16px calc(env(safe-area-inset-bottom) + 26px);
}

.auth__card {
  width: 100%;
  max-width: 398px;
  padding: 26px 22px;
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  animation: rise 0.5s var(--ease) both;
}

.auth__brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--muted);
  text-decoration: none;
}

.auth__brand svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.auth__card h1 {
  margin-top: 14px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.auth__lead {
  margin-top: 7px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  text-wrap: pretty;
}

.auth__form {
  display: grid;
  gap: 13px;
  margin-top: 18px;
}

.auth__error {
  min-height: 16px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--err);
}

.auth__error:empty {
  min-height: 0;
}

.auth__form .btn {
  margin-top: 2px;
}

.auth__switch {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.auth__switch a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.auth__switch a:hover {
  text-decoration: underline;
}

.auth__back {
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
}

.auth__back:hover {
  color: var(--ink);
}

/* 11. Motion & responsive ------------------------------------------------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes avatar-in {
  from {
    opacity: 0;
    transform: scale(0.86) rotate(-4deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pill-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%);
  }
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(4vw, 5vh, 0) scale(1.12);
  }
}

@keyframes shimmer {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -80% 0;
  }
}

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

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (min-width: 620px) {
  .theme-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .card {
    padding: 32px 26px 24px;
  }

  .link-btn__title {
    font-size: 15px;
  }
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 356px;
    align-items: start;
    gap: 22px;
    padding: 10px 24px 0;
  }

  .form {
    padding-bottom: 120px;
  }

  .topbar {
    padding-inline: 24px;
  }

  .preview {
    position: sticky;
    top: 76px;
  }

  .preview__close {
    display: none;
  }

  .phone__screen {
    min-height: 480px;
    max-height: calc(100vh - 190px);
  }

  .overlay {
    align-items: center;
  }

  .sheet {
    border-radius: 26px;
    padding-bottom: 22px;
  }
}

@media (max-width: 899px) {
  .preview {
    position: fixed;
    inset: 0;
    z-index: 45;
    padding: calc(env(safe-area-inset-top) + 10px) 14px
      calc(env(safe-area-inset-bottom) + 14px);
    background: var(--bg);
    transform: translateY(101%);
    transition: transform 0.45s var(--ease);
    overflow-y: auto;
    align-content: start;
    visibility: hidden;
  }

  .preview.is-open {
    transform: none;
    visibility: visible;
  }

  .preview__head {
    padding: 0 4px;
  }

  .phone__screen {
    max-height: none;
  }
}

@media (max-width: 380px) {
  .theme-tile__label {
    font-size: 10.5px;
  }

  .savebar .btn {
    min-width: 118px;
  }

  .topbar__sub {
    display: none;
  }
}

@media (hover: none) {
  .link-btn:hover {
    transform: none;
    border-color: var(--line);
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------- blocks */
.blocks {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.block {
  margin: 0;
}

.block--text {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  opacity: 0.92;
}

.block--heading {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--ink);
  margin-top: 2px;
}

.block--list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  opacity: 0.92;
  overflow-wrap: anywhere;
}

.block--list li::marker {
  color: var(--accent);
}

.block--quote {
  margin: 0;
  padding: 4px 0 4px 14px;
  border-left: 3px solid var(--accent);
  font-size: 14.5px;
  line-height: 1.55;
  font-style: italic;
  color: var(--ink);
  opacity: 0.9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.block--image {
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}

.block--image img {
  display: block;
  width: 100%;
  height: auto;
}

.block--divider {
  height: 1px;
  background: var(--line);
  margin: 2px 0;
}

.blocks-editor {
  display: grid;
  gap: 10px;
}

.block-row {
  display: grid;
  gap: 8px;
  padding: 11px;
  border-radius: 16px;
  background: var(--field);
  border: 1px solid var(--line);
  animation: rise 0.32s var(--ease) both;
}

.block-row__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.block-row__type {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.block-row__tools {
  display: flex;
  gap: 6px;
}

.block-row__image {
  display: grid;
  place-items: center;
  min-height: 76px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  border: 1px dashed var(--line);
}

.block-row__image img {
  display: block;
  width: 100%;
  height: auto;
}

.block-row__hint {
  padding: 18px;
  font-size: 13px;
  color: var(--muted);
}

.block-row__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.block-row__divider {
  height: 1px;
  background: var(--line);
}

.blocks-add {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
