html, body {
  margin: 0;
  padding: 0;
  background: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #262626;
}

.embed-body {
  padding: 8px;
}

.embed-card {
  max-width: 540px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #dbdbdb;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.embed-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #efefef;
}

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f58529, #dd2a7b, #8134af, #515bd4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.who strong { display: block; font-size: 14px; }
.who span { color: #8e8e8e; font-size: 12px; }

.embed-media { background: #000; }
.embed-media img, .embed-media video {
  display: block;
  width: 100%;
  max-height: 540px;
  object-fit: contain;
  margin: 0 auto;
}

.embed-foot { padding: 12px 14px 16px; }

.embed-foot .stats {
  display: flex;
  gap: 16px;
  font-size: 14px;
  margin-bottom: 8px;
}

.embed-foot .caption {
  font-size: 14px;
  white-space: pre-wrap;
  margin: 0 0 12px;
  max-height: 120px;
  overflow: hidden;
}

.view-link {
  color: #0095f6;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

/* ---------- Themed widget (driven by WidgetSettings) ---------- */

.embed-body.themed {
  background: transparent;
  color: var(--w-fg, #262626);
  font-family: var(--w-font, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif);
}

.embed-body.themed .embed-card {
  background: var(--w-bg, #fff);
  border-color: var(--w-border, #dbdbdb);
  border-radius: var(--w-radius, 8px);
}

.embed-body.themed .view-link { color: var(--w-accent, #0095f6); }

.widget-feed {
  display: grid;
  grid-template-columns: repeat(var(--w-cols, 3), minmax(0, 1fr));
  gap: var(--w-gap, 12px);
  padding: 8px;
}

.widget-feed--list {
  grid-template-columns: 1fr;
}

.widget-feed--carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 8px;
  gap: var(--w-gap, 12px);
}

.widget-feed--carousel .widget-card {
  flex: 0 0 220px;
  scroll-snap-align: start;
}

/* Masonry: CSS columns; natural aspect ratio on thumbs */
.widget-feed--masonry {
  display: block;
  column-count: var(--w-cols, 3);
  column-gap: var(--w-gap, 12px);
  padding: 8px;
}

.widget-feed--masonry .widget-card {
  break-inside: avoid;
  margin-bottom: var(--w-gap, 12px);
  display: inline-block;
  width: 100%;
}

.widget-feed--masonry .widget-thumb {
  aspect-ratio: auto;
  height: auto;
}

.widget-feed--masonry .widget-thumb img,
.widget-feed--masonry .widget-thumb video {
  height: auto;
  object-fit: contain;
}

/* Social wall: bento-style varied spans on a 4-col grid */
.widget-feed--social-wall {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 120px;
  grid-auto-flow: dense;
}

.widget-feed--social-wall .widget-card { grid-column: span 1; grid-row: span 2; }
.widget-feed--social-wall .widget-card--tile-1 { grid-column: span 2; grid-row: span 3; }
.widget-feed--social-wall .widget-card--tile-4 { grid-column: span 2; grid-row: span 2; }
.widget-feed--social-wall .widget-card--tile-6 { grid-column: span 1; grid-row: span 3; }
.widget-feed--social-wall .widget-card--tile-7 { grid-column: span 2; grid-row: span 2; }

.widget-feed--social-wall .widget-thumb { aspect-ratio: auto; height: 100%; }
.widget-feed--social-wall .widget-card { position: relative; overflow: hidden; }
.widget-feed--social-wall .widget-card .widget-thumb { position: absolute; inset: 0; }
.widget-feed--social-wall .widget-stats { color: #fff; }

/* Slider: full-width snap slider with arrows */
.widget-slider { position: relative; padding: 8px 40px; }
.widget-slider__track {
  display: flex;
  gap: var(--w-gap, 12px);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
}
.widget-slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
}
.widget-slider__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--w-border, #dbdbdb);
  background: #fff;
  color: var(--w-fg, #262626);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.widget-slider__arrow--prev { left: 4px; }
.widget-slider__arrow--next { right: 4px; }
.widget-slider__arrow:hover { background: var(--w-accent, #0095f6); color: #fff; border-color: transparent; }

/* Single post */
.widget-single {
  max-width: 560px;
  margin: 12px auto;
}
.widget-thumb--tall {
  aspect-ratio: 4 / 5;
}
.widget-caption--full {
  display: block;
  -webkit-line-clamp: unset;
  max-height: none;
}

/* ---------- Card hover + badges (Instagram-style) ---------- */

.widget-card { cursor: pointer; }

.widget-hover {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-weight: 700;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.widget-card:hover .widget-hover,
.widget-card:focus-visible .widget-hover { opacity: 1; }

.widget-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1;
}

.widget-meta--overlay {
  position: absolute;
  inset: auto 0 0 0;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.75) 100%);
  color: #fff;
  padding: 28px 12px 10px;
  pointer-events: none;
}
.widget-meta--overlay .widget-stats { color: #fff; }

/* ---------- Modal (Instagram-style lightbox) ---------- */

body.is-modal-open { overflow: hidden; }

.post-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  font-family: var(--w-font, inherit);
}

.post-modal[hidden] { display: none; }

.post-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
}

.post-modal__panel {
  position: relative;
  width: min(980px, 100%);
  max-height: calc(100vh - 32px);
  background: #fff;
  color: #262626;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
}

.post-modal__close {
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 2;
  background: rgba(255, 255, 255, 0.92);
  color: #262626;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.post-modal__close:hover { background: #fff; }

.post-modal__body { display: flex; flex: 1; min-height: 0; }

.post-modal__loading,
.post-modal__error {
  padding: 40px;
  text-align: center;
  flex: 1;
  font-size: 14px;
  color: #8e8e8e;
}
.post-modal__error a { color: var(--w-accent, #0095f6); font-weight: 600; }

.post-modal__grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  width: 100%;
  min-height: 0;
}

.post-modal__media {
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
}

.post-modal__media img,
.post-modal__media video {
  max-width: 100%;
  max-height: min(80vh, 720px);
  object-fit: contain;
  display: block;
  background: #000;
}

.post-modal__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: #262626;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.post-modal__nav--prev { left: 10px; }
.post-modal__nav--next { right: 10px; }

.post-modal__dots {
  position: absolute;
  bottom: 12px;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
}
.post-modal__dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
}
.post-modal__dots span.is-active { background: #fff; }

.post-modal__side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid #efefef;
}

.post-modal__head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #efefef;
}

.post-modal__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f58529, #dd2a7b, #8134af, #515bd4);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.post-modal__who { min-width: 0; }
.post-modal__who strong {
  display: block;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.post-modal__who span { color: #8e8e8e; font-size: 12px; }

.post-modal__cta {
  font-size: 12px;
  font-weight: 700;
  color: var(--w-accent, #0095f6);
  text-decoration: none;
  white-space: nowrap;
  padding: 6px 10px;
  border: 1px solid var(--w-accent, #0095f6);
  border-radius: 6px;
}
.post-modal__cta:hover {
  background: var(--w-accent, #0095f6);
  color: #fff;
}

.post-modal__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.45;
}

.post-modal__caption {
  margin: 0 0 12px;
  white-space: pre-wrap;
}

.post-modal__section {
  margin: 16px 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8e8e8e;
}

.post-modal__comments {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.post-modal__comments li { font-size: 13px; line-height: 1.45; }
.post-modal__comments em { font-style: normal; color: #8e8e8e; margin-left: 6px; }

.post-modal__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}
.post-modal__tag {
  background: #f1f5ff;
  color: var(--w-accent, #0095f6);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease;
}
.post-modal__tag:hover { background: #e1ebff; text-decoration: none; }

.post-modal__caption a {
  color: var(--w-accent, #0095f6);
  text-decoration: none;
  font-weight: 600;
}
.post-modal__caption a:hover { text-decoration: underline; }

.post-modal__tagged {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.post-modal__tagged li { font-size: 13px; }
.post-modal__tagged a {
  color: var(--w-accent, #0095f6);
  text-decoration: none;
  background: #f1f5ff;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.post-modal__tagged a:hover { background: #e1ebff; text-decoration: none; }
.post-modal__verified { color: #1da1f2; font-size: 11px; }

.post-modal__location,
.post-modal__music {
  margin: 0 0 6px;
  font-size: 13px;
  color: #8e8e8e;
}

.post-modal__foot {
  border-top: 1px solid #efefef;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #8e8e8e;
}

.post-modal__stats {
  display: flex;
  gap: 14px;
  font-weight: 600;
  color: #262626;
}

.post-modal__empty { margin: 0; }
.post-modal__placeholder {
  width: 100%; aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #222, #000);
}

@media (max-width: 760px) {
  .post-modal__panel { max-height: 100vh; border-radius: 0; }
  .post-modal__grid { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .post-modal__side { border-left: none; border-top: 1px solid #efefef; }
  .post-modal__media img,
  .post-modal__media video { max-height: 50vh; }
}

.widget-card {
  background: var(--w-bg, #fff);
  color: inherit;
  border: 1px solid var(--w-border, #dbdbdb);
  border-radius: var(--w-radius, 8px);
  overflow: hidden;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  transition: transform 0.1s ease-out, box-shadow 0.15s ease;
}

.widget-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

.widget-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000;
  overflow: hidden;
}

.widget-thumb img,
.widget-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.widget-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #eee, #ccc);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 700;
  font-size: clamp(28px, 6vw, 56px);
  letter-spacing: 0.5px;
}

.widget-placeholder--gradient {
  background: linear-gradient(135deg, #f58529 0%, #dd2a7b 50%, #515bd4 100%);
}

.widget-thumb img,
.widget-thumb video {
  font-size: 0; /* hide long overflow alt text if an image fails */
}

.widget-thumb img[alt]:after,
.widget-thumb video:after {
  content: '';
}

.post-modal__placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #222, #000);
  display: flex;
  align-items: center;
  justify-content: center;
}

.post-modal__placeholder--gradient {
  background: linear-gradient(135deg, #f58529 0%, #dd2a7b 50%, #515bd4 100%);
  color: #fff;
  font-weight: 700;
  font-size: 56px;
}

.widget-meta {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.widget-stats { color: var(--w-accent, #0095f6); font-weight: 600; }

.widget-caption {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: inherit;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.widget-empty {
  text-align: center;
  color: #8e8e8e;
  padding: 40px 0;
  margin: 0;
  font-size: 13px;
}

@media (max-width: 600px) {
  .widget-feed { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
