/* Instagram (module lens): app skin. Rules moved verbatim from styles.css (C1); the variables are the app identity, posture themes re-map the shell only. */
/* P9 scheme tokens: light = the colours these rules always used, dark = Instagram in its own dark theme. */
:root {
  --instagram-blue-text: #00376b;
  --instagram-line: #fff;
  --instagram-line-2: #efefef;
  --instagram-line-3: #e1dfdd;
  --instagram-shade: rgba(0,0,0,0);
  --instagram-surface: #fff;
  --instagram-surface-2: #fafafa;
  --instagram-surface-3: #efefef;
  --instagram-text: #262626;
}
[data-scheme="dark"] {
  --instagram-blue-text: #e0f1ff;
  --instagram-line: #040404;
  --instagram-line-2: #262626;
  --instagram-line-3: #100f0d;
  --instagram-shade: rgba(255, 255, 255, 0.0);
  --instagram-surface: #000000;
  --instagram-surface-2: #121212;
  --instagram-surface-3: #262626;
  --instagram-text: #f5f5f5;
}
.module-body[data-module="lens"] {
  --app-font: "Inter", "Open Sans", Arial, sans-serif;
  --app-accent: #0074cc; /* P9 contrast: #0095f6 was 3:1 as text and under white */
  --app-bg: #ffffff;
  --app-surface: #fafafa;
  --app-radius: 12px;
}

/* ---------- Lens / photo feed ---------- */
.lens-layout { max-width: 1000px; }
.lens-head { display: flex; align-items: center; gap: 16px; padding: 16px; background: var(--instagram-surface); border: 1px solid var(--border); border-radius: 8px; }
.lens-avatar { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 18px; color: #fff; background: linear-gradient(135deg,#f9ce34,#ee2a7b 55%,#6228d7); flex: none; }
.lens-avatar.small { width: 34px; height: 34px; font-size: 11px; }
.lens-profile-copy h2 { font-size: 19px; }
.lens-profile-copy p { font-size: 12.5px; color: var(--muted); }
.lens-stats { display: flex; gap: 16px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.lens-stats strong { color: var(--text); }
.lens-head .btn { margin-left: auto; }
.lens-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 12px; }
.lens-tile { position: relative; aspect-ratio: 1; background: var(--thumb); border-radius: 4px; overflow: hidden; }
.lens-tile-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px; color: #fff; font-size: 12px; font-weight: 600; background: var(--instagram-shade); opacity: 0; transition: opacity .15s; }
.lens-tile:hover .lens-tile-overlay { opacity: 1; background: rgba(0,0,0,0.35); }
.lens-modal { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); width: min(980px, 94vw); max-height: 88vh; background: var(--instagram-surface); border-radius: 8px; overflow: hidden; }
.lens-modal-media { position: relative; background: var(--thumb); min-height: 420px; }
.lens-modal-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,0.4); border-radius: 50%; }
.lens-modal-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.lens-modal-head { display: flex; align-items: center; gap: 9px; }
.lens-modal-head div { display: flex; flex-direction: column; line-height: 1.2; }
.lens-modal-head strong { font-size: 12.5px; }
.lens-modal-head small { font-size: 11px; color: var(--muted); }
.lens-caption { font-size: 13.5px; }
.lens-modal-actions { display: flex; gap: 8px; }
.lens-modal-actions .metric { border: 1px solid var(--border); }
.lens-note { font-size: 11px; color: var(--faint); margin-top: auto; }
@media (max-width: 900px) {
  .lens-grid { grid-template-columns: repeat(2, 1fr); }
  .lens-modal { grid-template-columns: 1fr; max-height: 90vh; overflow: auto; }
  .lens-modal-media { min-height: 280px; }
}

/* ---------- Instagram additions ---------- */
.lens-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--instagram-line-3); margin-bottom: 12px; }
.lens-tab { padding: 9px 14px; font-size: 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.lens-tab.is-active { color: var(--instagram-text); border-bottom-color: #262626; font-weight: 600; }
.lens-home { max-width: 620px; margin: 0 auto; }
.lens-stories { display: flex; gap: 14px; padding: 12px 4px 16px; overflow-x: auto; background: var(--instagram-surface); border: 1px solid var(--instagram-line-3); border-radius: 8px; margin-bottom: 12px; }
.lens-story { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 68px; }
.lens-story small { font-size: 10px; color: var(--muted); max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lens-story-ring { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 50%; background: var(--ring); padding: 3px; }
.lens-story-avatar { width: 100%; height: 100%; display: grid; place-items: center; border-radius: 50%; background: var(--instagram-surface); font-size: 11px; font-weight: 700; color: var(--instagram-text); border: 2px solid var(--instagram-line); }
.lens-feed { display: flex; flex-direction: column; gap: 14px; }
.lens-post { background: var(--instagram-surface); border: 1px solid var(--instagram-line-3); border-radius: 8px; overflow: hidden; }
.lens-post-head { display: flex; align-items: center; gap: 9px; padding: 10px 12px; }
.lens-post-head div { display: flex; flex-direction: column; line-height: 1.2; flex: 1; }
.lens-post-head strong { font-size: 12px; }
.lens-post-head small { font-size: 10.5px; color: var(--muted); }
.lens-post-media { display: block; width: 100%; aspect-ratio: 1.35; background: var(--thumb); }
.lens-post-actions { display: flex; align-items: center; gap: 4px; padding: 8px 12px 2px; }
.lens-spacer { flex: 1; }
.lens-post-body { padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.lens-post-body p { font-size: 12.5px; }
.lens-post-body strong { font-weight: 600; }
.lens-comment-form { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.lens-comment-form input { flex: 1; border: none; outline: none; background: none; font-size: 12px; border-top: 1px solid var(--instagram-line-2); padding-top: 8px; }
.lens-explore, .lens-reels { max-width: 1000px; }
.lens-reels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
.lens-reel { position: relative; aspect-ratio: 9 / 16; width: 100%; border: 0; padding: 0; border-radius: 0; background: var(--thumb); background-color: #1b1b1b; overflow: hidden; text-align: left; cursor: pointer; }
.lens-reel-play { position: absolute; top: 8px; right: 8px; color: #fff; background: rgba(0,0,0,0.35); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; }
.lens-reel-copy { position: absolute; left: 8px; right: 8px; bottom: 8px; color: #fff; display: flex; flex-direction: column; gap: 2px; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
.lens-reel-copy strong { font-size: 12.5px; }
.lens-reel-copy small { font-size: 10.5px; opacity: 0.85; }
.lens-bio { font-size: 12px; color: var(--muted); margin-top: 6px; }
.lens-comments { display: flex; flex-direction: column; gap: 8px; }
.lens-comments .comment { padding: 4px 0; }
.lens-comments .comment strong { font-size: 11.5px; }
.lens-comments .comment p { font-size: 12px; color: var(--muted); }
.story-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(4,8,11,0.78); display: grid; place-items: center; padding: 20px; }
.story-card { position: relative; width: min(360px, 94vw); height: min(640px, 86vh); border-radius: 12px; background: var(--story); overflow: hidden; display: flex; flex-direction: column; }
.story-progress { height: 3px; background: rgba(255,255,255,0.3); margin: 8px 10px 0; border-radius: 2px; }
.story-progress span { display: block; width: 62%; height: 100%; background: var(--instagram-surface); border-radius: 2px; }
.story-head { display: flex; align-items: center; gap: 9px; padding: 10px 12px; color: #fff; }
.story-head strong { flex: 1; font-size: 12.5px; }
.story-head .icon-btn { color: #fff; }
.story-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #fff; text-align: center; padding: 20px; }
.story-avatar-big { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 700; background: rgba(255,255,255,0.18); border: 2px solid rgba(255,255,255,0.6); }
.story-body p { font-size: 13px; max-width: 26ch; }
.story-play { width: 76px; height: 76px; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.6); }

/* --- C6 Instagram: feed with author header, carousel, stories ring, profile, Explore, DMs, phone bottom bar */
.module-body[data-module="lens"] { --lens-ink: #262626; --lens-muted: #6b6b6b; --lens-line: #dbdbdb; --lens-unseen: linear-gradient(45deg,#f9ce34,#ee2a7b 55%,#6228d7); }
.lens-layout { font-family: var(--app-font); color: var(--lens-ink); max-width: 480px; margin: 0 auto; }
.lens-topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--lens-line); background: var(--instagram-surface); }
.lens-wordmark { font-weight: 700; font-size: 20px; letter-spacing: -0.02em; }
.lens-dm-btn.is-on { color: var(--app-accent); }
.lens-tabs { display: flex; gap: 4px; padding: 6px; background: var(--instagram-surface); border-bottom: 1px solid var(--lens-line); }
.lens-tab { flex: 1; border: 0; background: none; padding: 8px 4px; font: inherit; font-size: 13px; color: var(--lens-muted); cursor: pointer; }
.lens-tab.is-active { color: var(--lens-ink); font-weight: 600; }
.lens-stories { display: flex; gap: 12px; overflow-x: auto; padding: 12px 14px; border-bottom: 1px solid var(--lens-line); background: var(--instagram-surface); }
.lens-story { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; font: inherit; font-size: 12px; cursor: pointer; min-width: 68px; position: relative; }
.lens-story-ring { width: 66px; height: 66px; border-radius: 50%; padding: 3px; background: var(--lens-line); display: grid; place-items: center; }
.lens-story.is-unseen .lens-story-ring { background: var(--lens-unseen); }
.lens-story-avatar { width: 58px; height: 58px; border-radius: 50%; background: var(--instagram-surface); display: grid; place-items: center; overflow: hidden; }
.lens-badge-expired { font-size: 10px; background: #8e8e8e; color: #fff; border-radius: 8px; padding: 1px 6px; }
.lens-new { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--lens-line); background: var(--instagram-surface); }
.lens-posting-as, .lens-note { font-size: 12px; color: var(--lens-muted); }
.lens-note { padding: 8px 14px; }
.lens-feed { background: var(--instagram-surface-2); }
.lens-post { background: var(--instagram-surface); border-bottom: 1px solid var(--lens-line); margin-bottom: 8px; }
.lens-post-head { display: flex; align-items: center; padding: 10px 12px; }
.lens-author { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0; font: inherit; cursor: pointer; text-align: left; }
.lens-author-copy { display: flex; flex-direction: column; font-size: 14px; }
.lens-author-copy small { color: var(--lens-muted); font-size: 12px; }
.lens-carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; aspect-ratio: 1 / 1; background: var(--instagram-surface-3); }
.lens-slide { flex: 0 0 100%; scroll-snap-align: start; border: 0; padding: 0; background: var(--thumb); background-color: var(--instagram-surface-3); cursor: pointer; }
.lens-dots { display: flex; justify-content: center; gap: 4px; padding: 6px 0 0; }
.lens-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--lens-line); }
.lens-dot.is-on { background: var(--app-accent); }
.lens-modal-carousel { position: absolute; inset: 0; aspect-ratio: auto; background: transparent; }
.lens-modal-dots { position: absolute; left: 0; right: 0; bottom: 8px; padding: 0; }
.lens-draft-list { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.lens-draft-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.lens-draft-thumb { width: 32px; height: 32px; flex: none; border-radius: 4px; background: var(--instagram-surface-3) center / cover no-repeat; }
.lens-draft-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lens-draft-item small { color: var(--lens-muted); }
.lens-post-actions { display: flex; align-items: center; gap: 12px; padding: 8px 12px 4px; }
.lens-post-actions .metric { border: 0; background: none; padding: 2px; cursor: pointer; color: var(--lens-ink); }
.lens-post-actions .metric.is-on { color: #ed4956; }
.lens-spacer { flex: 1; }
.lens-post-body { padding: 0 12px 12px; font-size: 14px; }
.lens-post-body p { margin: 4px 0; }
.lens-more summary { display: inline; color: var(--lens-muted); cursor: pointer; list-style: none; }
.lens-comment-line { color: var(--lens-ink); }
.lens-comment-form { display: flex; gap: 8px; border-top: 1px solid var(--lens-line); margin-top: 8px; padding-top: 6px; }
.lens-comment-form input { flex: 1; border: 0; outline: none; font: inherit; font-size: 14px; }
.lens-explore, .lens-reels, .lens-profile { padding: 0; }
.lens-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.lens-tile { position: relative; aspect-ratio: 1 / 1; border: 0; padding: 0; background: var(--thumb); background-color: var(--instagram-surface-3); cursor: pointer; }
.lens-tile-overlay { position: absolute; inset: auto 6px 6px auto; color: #fff; font-size: 12px; text-shadow: 0 1px 2px rgba(0,0,0,.5); opacity: 0; }
.lens-tile:hover .lens-tile-overlay, .lens-tile:focus-visible .lens-tile-overlay { opacity: 1; }
.lens-head { display: flex; gap: 20px; align-items: flex-start; padding: 18px 14px; background: var(--instagram-surface); border: 0; border-radius: 0; }
.lens-profile-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lens-profile-top h2 { font-size: 18px; margin: 0; font-weight: 400; }
.lens-stats { display: flex; gap: 14px; font-size: 14px; margin: 8px 0; }
.lens-name, .lens-bio, .lens-site { margin: 2px 0; font-size: 14px; }
.lens-site { color: var(--instagram-blue-text); }
.lens-profile-tabs { display: flex; border-top: 1px solid var(--lens-line); background: var(--instagram-surface); }
.lens-empty { padding: 28px 14px; text-align: center; color: var(--lens-muted); font-size: 14px; }
.lens-dm, .lens-dm-list { background: var(--instagram-surface); min-height: 260px; }
.lens-dm-list h2 { font-size: 16px; padding: 12px 14px; margin: 0; border-bottom: 1px solid var(--lens-line); }
.lens-dm-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.lens-dm-row small { display: block; color: var(--lens-muted); }
.lens-dm-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--lens-line); }
.lens-dm-thread { display: flex; flex-direction: column; gap: 6px; padding: 12px; max-height: 360px; overflow-y: auto; }
.lens-dm-msg { align-self: flex-start; max-width: 75%; background: var(--instagram-surface-3); border-radius: 18px; padding: 6px 12px; }
.lens-dm-msg.is-mine { align-self: flex-end; background: var(--app-accent); color: #fff; }
.lens-dm-msg small { display: block; font-size: 11px; opacity: .7; }
.lens-dm-msg p { margin: 0; font-size: 14px; }
.lens-dm form { padding: 8px 12px; }
.lens-story-viewer .story-card { max-width: 390px; }
/* phone width (390 px): the tab bar moves to the bottom of the screen, the way the real app lays it out */
@media (max-width: 600px) {
  .lens-layout { display: flex; flex-direction: column; min-height: 100%; max-width: none; }
  .lens-tabs { order: 9; position: sticky; bottom: 0; justify-content: space-around; border-top: 1px solid var(--lens-line); border-bottom: 0; }
  .lens-topbar { order: 0; }
  .lens-grid { grid-template-columns: repeat(3, 1fr); }
  .lens-head { flex-direction: column; align-items: center; text-align: center; }
  .lens-profile-top { justify-content: center; }
}
/* Explore, Reels and profiles use the wide desktop column (935 px, as the real site); the home feed stays narrow */
.lens-layout.is-wide { max-width: 935px; }
.lens-reel-copy strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lens-reel-copy small { display: inline-flex; align-items: center; gap: 3px; }
.reel-story { background: var(--story); background-color: #000; }
.reel-story .reel-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.reel-story .story-head { position: relative; z-index: 1; }
.reel-foot { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; padding: 40px 14px 14px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.reel-foot .lens-caption { margin: 0 0 4px; color: #fff; }
.reel-foot small { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; opacity: .9; }

/* Reels grid on desktop: four 9:16 tiles per row (Instagram's profile reels width), three on phones */
@media (min-width: 901px) {
  .lens-reels { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 935px; margin: 0 auto; }
}

/* --- T1 fidelity: native Instagram details (icons, time, likes line, suggested rail, desktop side nav) ---------- */
.lens-author-line { display: inline-flex; align-items: center; gap: 4px; }
.lens-dotsep { color: var(--lens-muted); }
.lens-time { color: var(--lens-muted); font-weight: 400; font-size: 14px; }
.lens-post-head .lens-spacer { flex: 1; }
.lens-more-btn { border: 0; background: none; padding: 4px; cursor: pointer; color: var(--lens-ink); }
.lens-post-actions .metric { color: var(--lens-ink); }
.lens-post-actions .metric.is-on .ico, .lens-modal-actions .metric.is-on .ico { color: #ff3040; fill: #ff3040; }
.lens-likes { margin: 2px 0 4px; font-size: 14px; }
.lens-likes.is-first { font-weight: 400; }
.lens-view-comments { color: var(--lens-muted); padding: 2px 0; }
.lens-modal-time { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; color: var(--lens-muted); letter-spacing: .02em; }
.lens-tab { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.lens-tab .lens-tab-ico { display: none; }
.lens-side { display: none; }
@media (max-width: 600px) {
  .lens-tab .lens-tab-ico { display: block; }
  .lens-tab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .lens-tab.is-active { color: var(--lens-ink); }
}
@media (min-width: 1100px) {
  .module-body[data-module="lens"] .lens-layout:not(.is-wide) { max-width: 940px; }
  .lens-layout:not(.is-wide) .lens-home { max-width: none; display: grid; grid-template-columns: minmax(0, 470px) 320px; column-gap: 56px; justify-content: center; align-items: start; }
  .lens-home > .lens-stories, .lens-home > .lens-new, .lens-home > .lens-note, .lens-home > .lens-feed { grid-column: 1; }
  .lens-home > .lens-side { display: block; grid-column: 2; grid-row: 1 / span 4; position: sticky; top: 12px; padding-top: 18px; font-size: 14px; }
  .lens-feed { background: var(--instagram-surface); }
  .lens-post { border: 0; border-bottom: 1px solid var(--lens-line); padding-bottom: 12px; }
}
.lens-side-me, .lens-side-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.lens-side-me > div, .lens-side-row .lens-author span { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.lens-side-row .lens-author { flex: 1; display: flex; align-items: center; gap: 12px; border: 0; background: none; text-align: left; cursor: pointer; font: inherit; padding: 0; }
.lens-side small { color: var(--lens-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lens-side .text-btn { color: var(--app-accent); font-weight: 600; font-size: 12px; }
.lens-side-head { display: flex; justify-content: space-between; margin: 6px 0 12px; color: var(--lens-muted); font-weight: 600; }
.lens-side-head .text-btn { color: var(--lens-ink); }
.lens-side-foot { color: var(--lens-muted); font-size: 11px; line-height: 1.6; margin-top: 22px; }

/* P9 dark scheme: the module tokens above, Instagram in its own dark theme */
[data-scheme="dark"] .module-body[data-module="lens"] {
  --app-bg: #000000;
  --app-surface: #121212;
  --lens-ink: #f5f5f5;
  --lens-muted: #a8a8a8;
  --lens-line: #363636;
  --lens-unseen: linear-gradient(45deg,#f9ce34,#ee2a7b 55%,#9c8bf9);
}
[data-scheme="dark"] .lens-side .text-btn { color: #4cb5f9; }
