/* ================================================
   ВизиткаNFC — страница визитки
   8 типов (tpl-*) с принципиально разной подачей.
   Базовые правила опираются на CSS-переменные,
   каждый тип переопределяет их + структуру.
   ================================================ */

:root {
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-pill: 999px;
  --sp-xs: 8px; --sp-sm: 12px; --sp-md: 16px; --sp-lg: 24px; --sp-xl: 32px;
}

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

html, body { min-height: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; line-height: 1.5; }
a { text-decoration: none; color: inherit; }

/* Embed / phone mockup: compact, centered, no scrollbars */
html:has(body.is-embed) {
  overflow: hidden !important;
  height: 100%;
  width: 100%;
}
body.is-embed {
  overflow: hidden !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
  height: 100%;
  width: 100%;
  max-width: 100%;
  margin: 0 !important;
  padding: 0 !important;
}
body.is-embed::-webkit-scrollbar,
html:has(body.is-embed)::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }
body.is-embed .bg { inset: 0; }
body.is-embed .sticky-save { display: none !important; }
body.is-embed .sheet { display: none !important; }
body.is-embed .card {
  min-height: 100%;
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 18px 12px 22px !important;
  overflow: hidden;
  box-sizing: border-box;
}
body.is-embed .avatar { width: 72px; height: 72px; margin-bottom: 10px; }
body.is-embed .hero { margin-bottom: 12px; }
body.is-embed .hero h1 {
  font-size: 1.15rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}
body.is-embed .pos { font-size: 12px; }
body.is-embed .company { font-size: 11px; }
body.is-embed .bio { font-size: 12px; margin-top: 8px; max-width: 100%; }
body.is-embed .save { margin: 12px 0 10px; padding: 11px 14px; font-size: 13px; border-radius: 10px; }
body.is-embed .tiles { gap: 6px; }
body.is-embed .tile { min-height: 68px; padding: 12px 6px; font-size: 11px; }
body.is-embed .tile .ic { width: 30px; height: 30px; }
body.is-embed .rows { gap: 6px; }
body.is-embed .row { padding: 10px 11px; font-size: 12px; }
body.is-embed .row .ic { width: 32px; height: 32px; }
body.is-embed .actions { gap: 6px; margin-top: 8px; }
body.is-embed .act { padding: 9px 4px; font-size: 10px; }
body.is-embed .foot { margin-top: 14px; margin-bottom: 0; font-size: 11px; }
/* layout-specific embed tweaks */
body.is-embed.lay-side .hero { gap: 10px; align-items: flex-start; }
body.is-embed.lay-side .avatar { width: 56px; height: 56px; flex: 0 0 56px; }
body.is-embed.lay-side .hero-text { min-width: 0; }
body.is-embed.lay-side .hero h1 { font-size: 1.05rem; white-space: normal; word-break: normal; }
body.is-embed.lay-cover .hero { margin-top: 96px; }
body.is-embed.lay-cover .avatar { width: 78px; height: 78px; }
body.is-embed.lay-cover .hero h1 { font-size: 1.25rem; }
body.is-embed.lay-stack .row { padding: 12px 36px; font-size: 12px; }
body.is-embed.lay-stack .row .ic { width: 28px; height: 28px; left: 10px; }
body.is-embed.tpl-corporate .card {
  margin: 10px !important;
  width: calc(100% - 20px) !important;
  min-height: calc(100% - 20px);
  border-radius: 14px;
}
body.is-embed.tpl-creative .card::after { top: 150px; }

/* ---- Defaults (classic palette) ---- */
body {
  font-family: 'Manrope', system-ui, sans-serif;
  --bg: #f4f5f8;
  --ink: #0f1115;
  --ink-muted: #3f4652;
  --ink-subtle: #6b7280;
  --ink-tertiary: #9aa1ad;
  --tile: #ffffff;
  --tile-br: #e6e8ec;
  --tile-br-h: #d2d6dd;
  --ic-bg: #f1f3f6;
  --ic-ink: var(--accent);
  --accent: #ff6a00;
  --on-accent: #ffffff;
  --save-bg: var(--accent);
  --save-ink: var(--on-accent);
  --surface: #ffffff;
  --card-max: 420px;
  color: var(--ink);
  background: var(--bg);
}
body.font-serif { font-family: 'Manrope', system-ui, sans-serif; }
body.font-serif h1, body.font-serif .company { font-family: 'Fraunces', Georgia, serif; }
body.font-rounded { font-family: 'Nunito', system-ui, sans-serif; }
body.font-mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; }
body.font-mono .hero h1 { font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; font-weight: 600; }

/* ---- Background layer ---- */
.bg { position: fixed; inset: 0; z-index: 0; background: var(--bg); }

/* ---- Card ---- */
.card {
  position: relative;
  z-index: 1;
  max-width: var(--card-max);
  margin: 0 auto;
  padding: 36px 18px 56px;
  min-height: 100vh;
}

/* ---- Avatar ---- */
.avatar {
  width: 104px; height: 104px;
  border-radius: var(--r-pill);
  object-fit: cover;
  display: block;
  margin: 0 auto var(--sp-md);
  border: 3px solid var(--accent);
  background: var(--tile);
}
.avatar-ph {
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 2.1rem; letter-spacing: -0.02em;
  color: #fff; background: var(--accent);
}

/* ---- Hero ---- */
.hero { text-align: center; margin-bottom: var(--sp-lg); }
.hero h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); margin: 0 0 6px; }
.pos { font-size: 14px; font-weight: 600; color: var(--ink-muted); margin-top: 4px; }
.company { font-size: 12px; font-weight: 700; color: var(--accent); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.08em; }
.bio { margin: var(--sp-md) auto 0; max-width: 34ch; font-size: 14px; color: var(--ink-subtle); line-height: 1.55; }

/* ---- Save CTA ---- */
.save {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-xs);
  width: 100%;
  margin: var(--sp-lg) 0 var(--sp-md);
  padding: 14px 18px;
  border-radius: var(--r-md);
  font: inherit; font-weight: 700; font-size: 15px;
  border: none; cursor: pointer;
  background: var(--save-bg); color: var(--save-ink);
  transition: transform .12s, box-shadow .2s, filter .15s;
  box-shadow: 0 8px 22px -8px var(--accent);
}
.save svg { width: 18px; height: 18px; }
.save:hover { transform: translateY(-1px); filter: brightness(1.05); }
.save.sm { padding: 11px; font-size: 14px; margin: var(--sp-xs) 0; box-shadow: none; }

/* ---- Tiles ---- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-xs); margin-bottom: var(--sp-xs); }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 18px 10px; min-height: 92px;
  border-radius: var(--r-lg);
  font-weight: 600; font-size: 13px;
  background: var(--tile); border: 1px solid var(--tile-br); color: var(--ink);
  transition: transform .12s, border-color .15s, box-shadow .2s;
}
.tile .ic { width: 38px; height: 38px; border-radius: var(--r-pill); display: flex; align-items: center; justify-content: center; background: var(--ic-bg); color: var(--ic-ink); }
.tile .ic svg { width: 19px; height: 19px; }
.tile:hover { transform: translateY(-2px); border-color: var(--tile-br-h); }

/* ---- Rows ---- */
.rows { display: flex; flex-direction: column; gap: var(--sp-xs); margin-bottom: var(--sp-xs); }
.row {
  display: flex; align-items: center; gap: var(--sp-sm);
  padding: 13px 15px; border-radius: var(--r-lg);
  font-weight: 600; font-size: 14px;
  background: var(--tile); border: 1px solid var(--tile-br); color: var(--ink);
  transition: border-color .15s, transform .12s;
}
.row .ic { width: 40px; height: 40px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--ic-bg); color: var(--ic-ink); }
.row .ic svg { width: 19px; height: 19px; }
.row small { display: block; font-weight: 600; font-size: 11px; color: var(--ink-subtle); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.row:hover { border-color: var(--tile-br-h); transform: translateY(-1px); }

/* ---- Actions ---- */
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-xs); margin-top: var(--sp-sm); }
.act {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 13px 6px; border-radius: var(--r-lg);
  border: 1px solid var(--tile-br); background: var(--tile); color: var(--ink-muted);
  cursor: pointer; font: inherit; font-size: 12px; font-weight: 600;
  transition: border-color .15s, transform .12s;
}
.act svg { width: 18px; height: 18px; }
.act:hover { border-color: var(--tile-br-h); transform: translateY(-1px); }

/* ---- Footer ---- */
.foot { text-align: center; margin-top: var(--sp-xl); font-size: 12px; color: var(--ink-tertiary); }
.foot a { color: var(--ink-tertiary); }
.foot b { color: var(--accent); }

/* ---- Sticky save ---- */
.sticky-save {
  display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  padding: 10px 14px; align-items: center; justify-content: space-between;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--tile-br);
}
.sticky-save.show { display: flex; }
.mini { display: flex; align-items: center; gap: var(--sp-sm); }
.mini-av { width: 34px; height: 34px; border-radius: var(--r-pill); object-fit: cover; }
.mini b { display: block; font-size: 14px; font-weight: 700; color: var(--ink); }
.mini small { color: var(--ink-subtle); font-size: 12px; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; background: var(--save-bg); color: var(--save-ink); border: none; cursor: pointer; }

/* ---- Sheets ---- */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: flex-end; justify-content: center; z-index: 50; padding: var(--sp-sm); }
.sheet.open { display: flex; }
.sheet-in { background: var(--surface); color: var(--ink); border-radius: var(--r-xl) var(--r-xl) var(--r-lg) var(--r-lg); padding: var(--sp-lg); width: 100%; max-width: 420px; text-align: center; max-height: 90vh; overflow: auto; border: 1px solid var(--tile-br); }
.sheet-in h3 { font-size: 18px; font-weight: 700; color: var(--ink); margin: 0 0 var(--sp-xs); }
.sheet-in img { width: 200px; height: 200px; margin: var(--sp-md) auto; display: block; border-radius: var(--r-xl); border: 1px solid var(--tile-br); }
.sheet-in .lnk { font-size: 12px; word-break: break-all; color: var(--ink-subtle); margin-bottom: var(--sp-sm); font-family: ui-monospace, Menlo, monospace; }
.sheet-in input, .sheet-in textarea { width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--tile-br); border-radius: var(--r-md); margin: var(--sp-xs) 0; font: inherit; font-size: 14px; color: var(--ink); text-align: left; }
.sheet-in textarea { resize: vertical; min-height: 70px; }
.sheet-in .close { margin-top: var(--sp-sm); background: transparent; border: 0; color: var(--ink-subtle); cursor: pointer; padding: var(--sp-sm); font: inherit; font-size: 14px; }
.sheet-in .close:hover { color: var(--ink); }
.muted { color: var(--ink-subtle); font-size: 13px; margin-top: var(--sp-xs); }

/* ---- Toast ---- */
#toast { opacity: 0; visibility: hidden; position: fixed; bottom: var(--sp-xl); left: 50%; transform: translateX(-50%) translateY(120%); background: #111827; color: #fff; padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-pill); z-index: 100; transition: .25s; font-size: 14px; font-weight: 600; box-shadow: 0 8px 32px rgba(0,0,0,.4); white-space: nowrap; }
#toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* ---- Empty hint (preview) ---- */
.empty-hint { text-align: center; padding: 20px 16px; margin-bottom: 14px; border-radius: var(--r-lg); border: 1px dashed var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.empty-hint .empty-ico { display: inline-flex; color: var(--accent); margin-bottom: 8px; }
.empty-hint .empty-ico svg { width: 28px; height: 28px; }
.empty-hint b { display: block; margin-bottom: 4px; }
.empty-hint p { margin: 0; font-size: 13px; opacity: .75; }

/* ---- Brand colours (global, recognizable) ---- */
.t-whatsapp  .ic { background: #25D366; color: #fff; }
.t-telegram  .ic { background: #229ED9; color: #fff; }
.t-instagram .ic { background: linear-gradient(45deg,#f09433,#dc2743,#bc1888); color: #fff; }
.t-vk        .ic { background: #0077FF; color: #fff; }
.t-viber     .ic { background: #7360F2; color: #fff; }
.t-youtube   .ic { background: #FF0000; color: #fff; }
.t-linkedin  .ic { background: #0A66C2; color: #fff; }
.t-tiktok    .ic { background: #111; color: #fff; }
.t-facebook  .ic { background: #1877F2; color: #fff; }
.t-x         .ic { background: #111; color: #fff; }

/* ============================================================
   LAYOUT VARIANTS (structure)
   ============================================================ */

/* stack — link-in-bio: крупные кнопки в столбик */
.lay-stack .avatar { width: 92px; height: 92px; }
.lay-stack .rows { gap: 10px; margin-top: var(--sp-xs); }
.lay-stack .row {
  position: relative; justify-content: center; text-align: center;
  padding: 17px 44px; border-radius: var(--r-pill);
  font-weight: 800; font-size: 15px;
  box-shadow: 0 6px 18px -10px rgba(0,0,0,.4);
}
.lay-stack .row .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; }
.lay-stack .row small { display: none; }
.lay-stack .row span:last-child { line-height: 1.1; }

/* side — деловая: фото слева + текстовый блок */
.lay-side .hero {
  display: flex;
  align-items: flex-start;
  text-align: left;
  gap: 14px;
  margin-bottom: var(--sp-md);
}
.lay-side .avatar {
  width: 76px; height: 76px;
  border-radius: var(--r-lg);
  margin: 0;
  flex: 0 0 76px;
}
.lay-side .hero-text {
  flex: 1 1 auto;
  min-width: 0; /* allow text to wrap instead of stacking letters */
  text-align: left;
}
.lay-side .hero h1 {
  font-size: 1.25rem;
  line-height: 1.25;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}
.lay-side .bio { margin-left: 0; text-align: left; max-width: none; }

/* cover — креатив: цветная обложка сверху */
.lay-cover .card { padding-top: 0; }
.lay-cover .hero { margin-top: 150px; }
.lay-cover .avatar { width: 112px; height: 112px; border-width: 5px; border-color: var(--surface); box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); }
.lay-cover .hero h1 { font-size: 1.9rem; font-weight: 800; }

/* icons — минимал: только круглые иконки */
.lay-icons .tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.lay-icons .tile { width: 60px; min-height: 0; padding: 0; border: 0; background: transparent; }
.lay-icons .tile:hover { transform: translateY(-3px); }
.lay-icons .tile .lb { display: none; }
.lay-icons .tile .ic { width: 58px; height: 58px; }

/* ============================================================
   TEMPLATES (palette + accents)
   ============================================================ */

/* 1. CLASSIC — defaults above, warm orange */
.tpl-classic { --accent: #ff6a00; }

/* 2. STACK — link-in-bio, peach */
.tpl-stack {
  --accent: #f97316;
  --bg: linear-gradient(180deg, #fff6ed 0%, #ffe8d6 100%);
  --tile: #ffffff; --tile-br: #ffd9bd; --ic-bg: #fff3e9;
}
.tpl-stack .bg { background: linear-gradient(180deg, #fff6ed 0%, #ffe8d6 100%); }

/* 3. CORPORATE — деловая, синий, карточка */
.tpl-corporate {
  --accent: #2563eb;
  --bg: #eef1f6;
  --tile: #ffffff; --tile-br: #e2e7ef; --ic-bg: #eef3ff; --surface: #ffffff;
}
.tpl-corporate .bg { background: #eef1f6; }
.tpl-corporate .card { background: #fff; max-width: 440px; margin-top: 24px; margin-bottom: 24px; min-height: calc(100vh - 48px); border-radius: var(--r-xl); border: 1px solid #e2e7ef; box-shadow: 0 20px 60px -30px rgba(15,23,42,.4); }
.tpl-corporate .card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 6px; border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--accent); }
.tpl-corporate .company { color: var(--accent); }
.tpl-corporate .row { border-left: 3px solid var(--accent); }

/* 4. CREATIVE — обложка, розовый */
.tpl-creative {
  --accent: #db2777;
  --bg: #ffffff; --surface: #ffffff;
  --tile: #fff5fa; --tile-br: #fbd0e4; --ic-bg: #ffe6f1;
}
.tpl-creative .bg { background: linear-gradient(135deg, #db2777 0%, #f97316 100%); }
.tpl-creative .card::after { content: ''; position: absolute; top: 230px; left: 0; right: 0; bottom: 0; background: #fff; border-radius: 28px 28px 0 0; z-index: -1; box-shadow: 0 -10px 40px -20px rgba(0,0,0,.3); }
.tpl-creative .hero h1 { letter-spacing: -0.03em; }
.tpl-creative .company { color: var(--accent); }

/* 5. ELEGANT — тёмная премиум, золото, сериф */
.tpl-elegant {
  --accent: #c9a227;
  --bg: #0e0d0c;
  --ink: #f4efe6; --ink-muted: #cbc3b4; --ink-subtle: #9a9183; --ink-tertiary: #6f685c;
  --tile: rgba(255,255,255,.04); --tile-br: rgba(201,162,39,.28); --tile-br-h: rgba(201,162,39,.55);
  --ic-bg: rgba(201,162,39,.14); --ic-ink: #e8c547;
  --save-bg: linear-gradient(135deg,#c9a227,#e8c547); --save-ink: #0e0d0c;
  --surface: #17150f;
}
.tpl-elegant .bg { background: radial-gradient(120% 80% at 50% -10%, #241f16 0%, #0e0d0c 60%); }
.tpl-elegant .avatar { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(201,162,39,.4), 0 10px 30px -10px #000; }
.tpl-elegant .company { letter-spacing: 0.14em; }
.tpl-elegant .tile, .tpl-elegant .row { backdrop-filter: blur(6px); }
.tpl-elegant .row { background: transparent; border: 0; border-bottom: 1px solid rgba(201,162,39,.2); border-radius: 0; }
.tpl-elegant .row:hover { background: rgba(255,255,255,.03); }
.tpl-elegant .act { background: rgba(255,255,255,.03); }
.tpl-elegant #toast { background: #c9a227; color: #0e0d0c; }

/* 6. MINIMAL — белый, воздух */
.tpl-minimal {
  --accent: #111827;
  --bg: #ffffff;
  --ink: #0b0d10; --ink-muted: #4b5563; --ink-subtle: #9ca3af;
  --tile: #ffffff; --tile-br: #ececf0; --ic-bg: #f5f6f8; --ic-ink: #111827;
  --save-bg: #111827; --save-ink: #fff;
}
.tpl-minimal .bg { background: #fff; }
.tpl-minimal .card { padding-top: 56px; }
.tpl-minimal .avatar { width: 96px; height: 96px; border: 1px solid #ececf0; }
.tpl-minimal .hero h1 { font-weight: 600; letter-spacing: -0.03em; }
.tpl-minimal .save { background: #111827; box-shadow: none; }
.tpl-minimal .lay-icons .tile .ic, .tpl-minimal .tile .ic { border: 1px solid #ececf0; }

/* 7. NEON — тёмная техно */
.tpl-neon {
  --accent: #22d3ee;
  --bg: #07080f;
  --ink: #e8ecff; --ink-muted: #aab3d6; --ink-subtle: #7681a8; --ink-tertiary: #555f85;
  --tile: rgba(255,255,255,.04); --tile-br: rgba(34,211,238,.28); --tile-br-h: rgba(34,211,238,.6);
  --ic-bg: rgba(34,211,238,.14); --ic-ink: #22d3ee;
  --save-bg: linear-gradient(135deg,#22d3ee,#8b5cf6); --save-ink: #07080f;
  --surface: #11131f;
}
.tpl-neon .bg {
  background:
    radial-gradient(100% 60% at 50% 0%, rgba(34,211,238,.18), transparent 60%),
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px) 0 0/26px 26px,
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px) 0 0/26px 26px,
    #07080f;
}
.tpl-neon .avatar { box-shadow: 0 0 0 1px rgba(34,211,238,.5), 0 0 30px -4px rgba(34,211,238,.5); }
.tpl-neon .hero h1 { text-shadow: 0 0 24px rgba(34,211,238,.35); }
.tpl-neon .tile, .tpl-neon .row { backdrop-filter: blur(8px); }
.tpl-neon .tile:hover { box-shadow: 0 0 20px -6px rgba(34,211,238,.5); }
.tpl-neon .act { background: rgba(255,255,255,.03); }

/* 8. VIBRANT — яркий градиент */
.tpl-vibrant {
  --accent: #ffffff;
  --bg: linear-gradient(140deg, #ff6a00 0%, #f43f5e 55%, #a21caf 100%);
  --ink: #ffffff; --ink-muted: rgba(255,255,255,.88); --ink-subtle: rgba(255,255,255,.72); --ink-tertiary: rgba(255,255,255,.55);
  --tile: rgba(255,255,255,.16); --tile-br: rgba(255,255,255,.28); --tile-br-h: rgba(255,255,255,.55);
  --ic-bg: rgba(255,255,255,.22); --ic-ink: #fff;
  --save-bg: #fff; --save-ink: #db2777;
  --surface: #a21caf;
}
.tpl-vibrant .bg { background: linear-gradient(140deg, #ff6a00 0%, #f43f5e 55%, #a21caf 100%); background-size: 180% 180%; animation: vibshift 14s ease infinite; }
@keyframes vibshift { 0%,100% { background-position: 0 50%; } 50% { background-position: 100% 50%; } }
.tpl-vibrant .avatar { border-color: rgba(255,255,255,.7); }
.tpl-vibrant .company { color: #fff; opacity: .95; }
.tpl-vibrant .tile, .tpl-vibrant .row, .tpl-vibrant .act { backdrop-filter: blur(10px); }
.tpl-vibrant .save { box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); }
.tpl-vibrant .sheet-in { color: #fff; }
.tpl-vibrant .sheet-in input, .tpl-vibrant .sheet-in textarea { background: rgba(255,255,255,.14); color: #fff; }

/* accent override hook (user colour) */
body[style*="--accent"] .company { color: var(--accent); }

/* ---- Responsive ---- */
@media (max-width: 420px) {
  .card { padding: 28px 14px 44px; }
  .hero h1 { font-size: 1.4rem; }
  .lay-cover .hero h1 { font-size: 1.6rem; }
}

/* ---- ticket layout: boarding-pass ---- */
.lay-ticket .card {
  margin: 20px 14px;
  max-width: calc(100% - 28px);
  min-height: calc(100vh - 40px);
  border-radius: 18px;
  background: var(--surface);
  border: 1.5px dashed color-mix(in srgb, var(--accent) 35%, #94a3b8);
  position: relative;
  overflow: hidden;
}
.lay-ticket .card::before,
.lay-ticket .card::after {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  background: var(--bg);
  border-radius: 50%;
  left: -11px;
  z-index: 2;
}
.lay-ticket .card::before { top: 38%; }
.lay-ticket .card::after { top: 38%; left: auto; right: -11px; }
.lay-ticket .hero { text-align: left; border-bottom: 1.5px dashed color-mix(in srgb, var(--accent) 25%, #cbd5e1); padding-bottom: 16px; margin-bottom: 16px; }
.lay-ticket .avatar { width: 64px; height: 64px; border-radius: 12px; margin: 0 0 12px; border-width: 2px; }
.lay-ticket .hero h1 { font-size: 1.35rem; text-transform: uppercase; letter-spacing: 0.04em; }
.lay-ticket .company { letter-spacing: 0.18em; font-size: 11px; }
.lay-ticket .bio { max-width: none; text-align: left; font-size: 13px; }
.lay-ticket .save { border-radius: 8px; text-transform: uppercase; letter-spacing: 0.06em; font-size: 13px; }
.lay-ticket .row {
  border: 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--accent) 18%, #e2e8f0);
  border-radius: 0;
  background: transparent;
  padding: 12px 4px;
}
.lay-ticket .row:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.lay-ticket .row small { letter-spacing: 0.12em; }
.lay-ticket .actions { margin-top: 14px; }
.lay-ticket .foot {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1.5px dashed color-mix(in srgb, var(--accent) 25%, #cbd5e1);
  font-family: ui-monospace, Menlo, monospace;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ---- poster layout: asymmetric bauhaus ---- */
.lay-poster .card { padding-top: 28px; overflow: hidden; }
.lay-poster .hero { position: relative; text-align: left; padding-left: 8px; margin-bottom: 20px; }
.lay-poster .avatar {
  width: 120px; height: 120px;
  border-radius: 8px;
  margin: 0 0 16px auto;
  border-width: 0;
  box-shadow: 10px 10px 0 var(--accent);
  position: relative;
  z-index: 1;
}
.lay-poster .hero-text { position: relative; z-index: 1; }
.lay-poster .hero h1 {
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  font-weight: 700;
  max-width: 12ch;
}
.lay-poster .pos { font-size: 13px; margin-top: 10px; text-transform: uppercase; letter-spacing: 0.14em; }
.lay-poster .company {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  background: var(--accent);
  color: #fff;
  border-radius: 0;
  letter-spacing: 0.08em;
}
.lay-poster .bio { max-width: none; text-align: left; margin-top: 14px; }
.lay-poster .save {
  border-radius: 0;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%);
  justify-content: flex-start;
  padding-left: 20px;
}
.lay-poster .tiles { grid-template-columns: 1fr; gap: 8px; }
.lay-poster .tile {
  flex-direction: row;
  justify-content: flex-start;
  min-height: 0;
  padding: 12px 14px;
  border-radius: 0;
  gap: 12px;
  border-left: 4px solid var(--accent);
}
.lay-poster .tile .ic { border-radius: 0; }
.lay-poster .act { border-radius: 0; }
.lay-poster .bg::before {
  content: '';
  position: absolute;
  width: 55%; height: 38%;
  top: -6%; right: -8%;
  background: var(--accent);
  opacity: .14;
  transform: rotate(18deg);
  pointer-events: none;
}
.lay-poster .bg::after {
  content: '';
  position: absolute;
  width: 90px; height: 90px;
  bottom: 12%; left: -20px;
  border: 8px solid var(--accent);
  opacity: .2;
  border-radius: 50%;
  pointer-events: none;
}

/* 9. TICKET palette */
.tpl-ticket {
  --accent: #0f172a;
  --bg: #f1f5f9;
  --ink: #0f172a; --ink-muted: #334155; --ink-subtle: #64748b; --ink-tertiary: #94a3b8;
  --tile: #fff; --tile-br: #e2e8f0; --ic-bg: #e2e8f0; --ic-ink: #0f172a;
  --save-bg: #0f172a; --save-ink: #f8fafc;
  --surface: #ffffff;
}
.tpl-ticket .bg {
  background:
    repeating-linear-gradient(90deg, transparent, transparent 11px, rgba(15,23,42,.04) 11px, rgba(15,23,42,.04) 12px),
    #e2e8f0;
}
.tpl-ticket .company { color: #0f172a; }
.tpl-ticket .avatar-ph { background: #0f172a; color: #fff; }

/* 10. POSTER palette */
.tpl-poster {
  --accent: #ea580c;
  --bg: #fff7ed;
  --ink: #1c1917; --ink-muted: #44403c; --ink-subtle: #78716c; --ink-tertiary: #a8a29e;
  --tile: #ffffff; --tile-br: #fed7aa; --ic-bg: #ffedd5; --ic-ink: #ea580c;
  --save-bg: #ea580c; --save-ink: #fff7ed;
  --surface: #fff7ed;
}
.tpl-poster .bg { background: #fff7ed; }
.tpl-poster .hero h1 { color: #1c1917; }
.tpl-poster .avatar-ph { background: #ea580c; color: #fff; border-radius: 8px; }

/* embed tweaks for new layouts */
body.is-embed.lay-ticket .card { margin: 10px !important; width: calc(100% - 20px) !important; min-height: calc(100% - 20px); padding: 16px 12px !important; }
body.is-embed.lay-ticket .avatar { width: 48px; height: 48px; }
body.is-embed.lay-ticket .hero h1 { font-size: 1.05rem; }
body.is-embed.lay-poster .avatar { width: 78px; height: 78px; box-shadow: 6px 6px 0 var(--accent); }
body.is-embed.lay-poster .hero h1 { font-size: 1.45rem; max-width: 11ch; }
body.is-embed.lay-poster .tile { padding: 10px 12px; }

/* ---- academic layout: formal diploma / faculty card ---- */
.lay-academic .card {
  margin: 22px 16px;
  max-width: calc(100% - 32px);
  min-height: calc(100vh - 44px);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, #d6d3d1);
  box-shadow: inset 0 0 0 6px color-mix(in srgb, var(--accent) 8%, transparent), 0 16px 40px -24px rgba(0,0,0,.35);
  border-radius: 4px;
  padding-top: 28px;
  position: relative;
}
.lay-academic .card::before {
  content: '';
  position: absolute;
  top: 10px; left: 10px; right: 10px;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.lay-academic .hero { text-align: center; }
.lay-academic .avatar {
  width: 88px; height: 88px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}
.lay-academic .hero h1 {
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 4px;
}
.lay-academic .hero h1::after {
  content: '';
  display: block;
  width: 72px; height: 1px;
  margin: 12px auto 0;
  background: var(--accent);
}
.lay-academic .pos {
  margin-top: 12px;
  font-style: italic;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.01em;
}
.lay-academic .company {
  margin-top: 6px;
  letter-spacing: 0.16em;
  font-size: 11px;
}
.lay-academic .bio {
  max-width: 36ch;
  font-size: 13.5px;
  line-height: 1.65;
}
.lay-academic .save {
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
  box-shadow: none;
}
.lay-academic .row {
  border-radius: 2px;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, #e7e5e4);
}
.lay-academic .row .ic { border-radius: 2px; }
.lay-academic .act { border-radius: 2px; }
.lay-academic .foot {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  letter-spacing: 0.04em;
}

/* ---- coder layout: terminal / IDE card ---- */
.lay-coder .card {
  margin: 18px 12px;
  max-width: calc(100% - 24px);
  min-height: calc(100vh - 36px);
  background: var(--surface);
  border: 1px solid var(--tile-br);
  border-radius: 12px;
  padding-top: 42px;
  box-shadow: 0 20px 50px -20px rgba(0,0,0,.7);
  overflow: hidden;
}
.lay-coder .card::before {
  content: '● ● ●  profile.json';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-subtle);
  background: color-mix(in srgb, var(--surface) 70%, #000);
  border-bottom: 1px solid var(--tile-br);
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}
.lay-coder .hero { text-align: left; }
.lay-coder .avatar {
  width: 64px; height: 64px;
  border-radius: 8px;
  margin: 0 0 14px;
  border: 1px solid var(--tile-br);
  box-shadow: none;
}
.lay-coder .hero h1 {
  font-size: 1.15rem;
  font-weight: 600;
}
.lay-coder .hero h1::before {
  content: '> ';
  color: var(--accent);
}
.lay-coder .pos {
  font-size: 12px;
  color: var(--ink-subtle);
  margin-top: 6px;
}
.lay-coder .pos::before { content: '// '; color: var(--ink-tertiary); }
.lay-coder .company {
  margin-top: 4px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  color: var(--accent);
}
.lay-coder .company::before { content: '@'; opacity: .7; }
.lay-coder .bio {
  max-width: none;
  text-align: left;
  font-size: 12.5px;
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  margin-top: 12px;
  color: var(--ink-muted);
}
.lay-coder .save {
  border-radius: 6px;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0;
  box-shadow: 0 0 20px -6px var(--accent);
}
.lay-coder .save span::before { content: '$ '; opacity: .7; }
.lay-coder .rows { gap: 0; border: 1px solid var(--tile-br); border-radius: 8px; overflow: hidden; }
.lay-coder .row {
  border: 0;
  border-bottom: 1px solid var(--tile-br);
  border-radius: 0;
  background: transparent;
  padding: 10px 12px;
  font-size: 12px;
}
.lay-coder .row:last-child { border-bottom: 0; }
.lay-coder .row:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.lay-coder .row small {
  text-transform: none;
  letter-spacing: 0;
  font-size: 10px;
  color: #79c0ff;
}
.lay-coder .row small::after { content: ':'; }
.lay-coder .row .ic {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}
.lay-coder .actions { gap: 8px; }
.lay-coder .act {
  border-radius: 6px;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 10px;
  background: color-mix(in srgb, var(--surface) 80%, #000);
}
.lay-coder .foot {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
}
.lay-coder .foot::before { content: '// '; opacity: .5; }

/* 11. ACADEMIC palette */
.tpl-academic {
  --accent: #7f1d1d;
  --bg: #ebe4d4;
  --ink: #1c1917; --ink-muted: #44403c; --ink-subtle: #78716c; --ink-tertiary: #a8a29e;
  --tile: #faf6ee; --tile-br: #d6d3d1; --ic-bg: #f0e7d8; --ic-ink: #7f1d1d;
  --save-bg: #7f1d1d; --save-ink: #faf6ee;
  --surface: #f7f1e5;
}
.tpl-academic .bg {
  background:
    radial-gradient(circle at 20% 10%, rgba(127,29,29,.08), transparent 40%),
    #ebe4d4;
}
.tpl-academic .company { color: #7f1d1d; }
.tpl-academic .avatar-ph { background: linear-gradient(135deg, #a16207, #7f1d1d); color: #fff; }

/* 12. CODER palette */
.tpl-coder {
  --accent: #3fb950;
  --bg: #010409;
  --ink: #e6edf3; --ink-muted: #c9d1d9; --ink-subtle: #8b949e; --ink-tertiary: #6e7681;
  --tile: #161b22; --tile-br: #30363d; --ic-bg: #21262d; --ic-ink: #3fb950;
  --save-bg: #238636; --save-ink: #ffffff;
  --surface: #0d1117;
}
.tpl-coder .bg {
  background:
    linear-gradient(rgba(63,185,80,.04) 1px, transparent 1px) 0 0/24px 24px,
    linear-gradient(90deg, rgba(63,185,80,.04) 1px, transparent 1px) 0 0/24px 24px,
    #010409;
}
.tpl-coder .avatar-ph { background: #21262d; color: #3fb950; border-radius: 8px; }
.tpl-coder #toast { background: #238636; color: #fff; }

/* embed tweaks */
body.is-embed.lay-academic .card { margin: 10px !important; width: calc(100% - 20px) !important; min-height: calc(100% - 20px); padding: 18px 12px 16px !important; }
body.is-embed.lay-academic .avatar { width: 64px; height: 64px; }
body.is-embed.lay-academic .hero h1 { font-size: 1.2rem; }
body.is-embed.lay-coder .card { margin: 8px !important; width: calc(100% - 16px) !important; min-height: calc(100% - 16px); padding: 36px 12px 14px !important; }
body.is-embed.lay-coder .card::before { height: 28px; font-size: 10px; }
body.is-embed.lay-coder .avatar { width: 48px; height: 48px; }
body.is-embed.lay-coder .hero h1 { font-size: 1rem; }

/* language links in card footer */
.foot-lang { display: inline-flex; gap: 2px; margin-left: 10px; }
.foot-lang a { padding: 2px 6px; border-radius: 6px; font-size: 11px; font-weight: 700; opacity: .6; text-decoration: none; color: inherit; }
.foot-lang a.on { opacity: 1; background: color-mix(in srgb, currentColor 12%, transparent); }
