/* ===================== TRANG CHỦ KIỂU INSTAGRAM (.ig-) ===================== */
.ig-root { height: 100%; background: var(--bg-elev); }
.ig-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; }
.ig-col { max-width: 470px; margin: 0 auto; padding: 16px 12px 56px; }
.ig-col--wide { max-width: 935px; padding-top: 28px; }
.ig-top { display: flex; align-items: center; justify-content: space-between; padding: 0 0 12px; }
.ig-top h1 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.01em; }
.ig-iconbtn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-pill); color: var(--text); transition: transform var(--dur-fast), background var(--dur-fast); }
.ig-iconbtn:hover { background: var(--hover); }
.ig-iconbtn:active { transform: scale(.9); }
.ig-iconbtn.is-liked { color: var(--danger); }
.ig-name { font-weight: 600; color: var(--text); }
.ig-name:hover { text-decoration: underline; }

/* ---------- Stories ---------- */
.ig-stories-wrap { border-bottom: 1px solid var(--border); margin: 0 -12px 12px; padding: 0 12px 14px; }
.ig-stories { display: flex; gap: 14px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.ig-stories::-webkit-scrollbar { display: none; }
.ig-story { flex: none; width: 72px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ig-story__av { position: relative; display: inline-grid; place-items: center; width: 70px; height: 70px; border-radius: 50%; }
.ig-story__av.ig-ring { padding: 3px; }
.ig-story__name { max-width: 72px; font-size: var(--fs-xs); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ig-story__plus { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; border: 2px solid var(--bg-elev); }
.ig-story__av--plus { border: 1.5px dashed var(--border-strong); color: var(--text-2); }
.ig-ring { display: inline-flex; padding: 2px; border-radius: 50%; background: var(--brand-grad); }
.ig-ring.is-seen { background: var(--border-strong); }
.ig-ring .kit-avatar { box-shadow: 0 0 0 2px var(--bg-elev); }
.ig-plainav { display: inline-flex; border-radius: 50%; }

/* ---------- Bài đăng ---------- */
.ig-feed { display: flex; flex-direction: column; }
.ig-post { padding: 4px 0 8px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.ig-post__head { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.ig-post__who { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.ig-post__who small { color: var(--text-3); display: inline-flex; align-items: center; gap: 2px; }
.ig-media { position: relative; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface-3); }
.ig-media__track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.ig-media__track::-webkit-scrollbar { display: none; }
.ig-media__slide { flex: 0 0 100%; scroll-snap-align: start; aspect-ratio: 1 / 1; display: block; padding: 0; cursor: pointer; }
.ig-media__slide img { width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; }
.ig-media__dots { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; gap: 5px; pointer-events: none; }
.ig-media__dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .55); box-shadow: 0 0 2px rgba(0, 0, 0, .4); }
.ig-media__dots i.is-on { background: #fff; }
.ig-pop { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; opacity: 0; pointer-events: none; filter: drop-shadow(0 4px 16px rgba(0, 0, 0, .45)); }
.ig-pop.is-on { animation: ig-pop .8s var(--ease); }
@keyframes ig-pop { 0% { opacity: 0; transform: scale(.4); } 20% { opacity: 1; transform: scale(1.15); } 40% { transform: scale(.95); } 80% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1); } }
.ig-post__body { font-size: var(--fs-lg); line-height: 1.5; padding: 6px 0 4px; white-space: pre-wrap; word-break: break-word; }
.ig-actions { display: flex; gap: 2px; margin: 4px -8px 0; }
.ig-likes { font-weight: 600; margin: 2px 0 4px; }
.ig-caption { margin: 2px 0 4px; white-space: pre-wrap; word-break: break-word; }
.ig-comments { display: flex; flex-direction: column; gap: 3px; font-size: var(--fs-md); }
.ig-comment { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; word-break: break-word; }
.ig-cdel { color: var(--text-3); flex: none; margin-top: 3px; opacity: 0; }
.ig-comment:hover .ig-cdel, .ig-cdel:focus-visible { opacity: 1; }
.ig-more { color: var(--text-3); text-align: left; padding: 2px 0; }
.ig-crow { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.ig-cinput { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); padding: 6px 0; font-size: var(--fs-md); }
.ig-cinput::placeholder { color: var(--text-3); }
.ig-csend { color: var(--accent); font-weight: 700; }
html:is([data-accent="classic"], [data-accent="tam"]) .ig-csend { color: #0095f6; }
.ig-empty { padding: 40px 0; }
.ig-empty__btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Lưới ảnh (Khám phá, hồ sơ) ---------- */
.ig-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.ig-grid > .kit-empty { grid-column: 1 / -1; }
.ig-tile { position: relative; aspect-ratio: 1 / 1; overflow: hidden; background: var(--surface-3); padding: 0; display: block; cursor: pointer; }
.ig-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ig-tile.is-text { background: var(--surface-2); display: grid; align-items: center; }
.ig-tile__text { padding: 12px; font-size: var(--fs-sm); text-align: left; display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; color: var(--text); }
.ig-tile__multi { position: absolute; top: 8px; right: 8px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.ig-tile__over { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 20px; background: rgba(0, 0, 0, .38); color: #fff; opacity: 0; transition: opacity var(--dur-fast); }
.ig-tile__over b { display: inline-flex; align-items: center; gap: 5px; }
.ig-tile:hover .ig-tile__over, .ig-tile:focus-visible .ig-tile__over { opacity: 1; }

/* ---------- Trang cá nhân ---------- */
.ig-prof { display: flex; gap: 36px; align-items: flex-start; padding: 0 12px 28px; }
.ig-prof__av { flex: none; display: flex; justify-content: center; width: 150px; }
.ig-prof__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.ig-prof__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ig-prof__row h2 { font-size: var(--fs-xl); font-weight: 500; margin-right: 6px; }
.ig-prof__stats { display: flex; gap: 28px; list-style: none; padding: 0; margin: 0; }
.ig-prof__tools { display: flex; gap: 2px; margin-left: -8px; }
.ig-prof__user { color: var(--text-3); }
.ig-prof__status { font-weight: 600; }
.ig-prof__bio { white-space: pre-wrap; color: var(--text); }
.ig-tabs { display: flex; justify-content: center; border-top: 1px solid var(--border); margin-bottom: 4px; }
.ig-tabs span { display: inline-flex; align-items: center; gap: 6px; padding: 14px 4px; margin-top: -1px; border-top: 1px solid var(--text); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }

/* ---------- Cửa sổ chi tiết bài ---------- */
.ig-detail-shell { width: min(480px, 96vw); }
.ig-detail { position: relative; max-height: 90vh; overflow-y: auto; background: var(--surface); border-radius: var(--r-lg); padding: 4px 14px 10px; }
.ig-detail .ig-post { border-bottom: 0; margin-bottom: 0; }
.ig-detail__close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text); }
.ig-detail .ig-post__head { padding-right: 40px; }

/* ---------- Tạo bài / Tạo tin ---------- */
.ig-cp__wrap { display: flex; flex-direction: column; gap: 14px; }
.ig-cp__who { display: flex; align-items: center; gap: 10px; }
.ig-cp__thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.ig-cp__thumb, .ig-cp__add { position: relative; width: 92px; height: 92px; border-radius: 8px; overflow: hidden; }
.ig-cp__thumb img { width: 100%; height: 100%; object-fit: cover; }
.ig-cp__thumb button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; color: #fff; background: rgba(0, 0, 0, .6); display: grid; place-items: center; }
.ig-cp__add { border: 1.5px dashed var(--border-strong); color: var(--text-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: var(--fs-xs); text-align: center; padding: 4px; }
.ig-cp__add:hover { background: var(--hover); }
.ig-cp__ta { width: 100%; resize: vertical; min-height: 96px; border: 0; outline: 0; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; color: var(--text); }
.ig-cp__vis { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 600; }
.ig-sc__wrap { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.ig-sc__frame { position: relative; aspect-ratio: 9 / 16; max-height: 54vh; margin: 0 auto; width: auto; height: 54vh; max-width: 100%; border-radius: 12px; overflow: hidden; }
.ig-sc__preview { position: absolute; inset: 0; }
.ig-sc__preview img { width: 100%; height: 100%; object-fit: cover; }
.ig-sc__ta { position: absolute; left: 12px; right: 12px; top: 50%; transform: translateY(-50%); background: transparent; border: 0; outline: 0; resize: none; color: #fff; text-align: center; font-size: 22px; font-weight: 700; line-height: 1.3; text-shadow: 0 1px 6px rgba(0, 0, 0, .4); }
.ig-sc__ta::placeholder { color: rgba(255, 255, 255, .7); }
.ig-sc__frame:has(img) .ig-sc__ta { top: auto; bottom: 14px; transform: none; font-size: 16px; background: rgba(0, 0, 0, .45); border-radius: 8px; padding: 8px; }
.ig-sc__palette { display: flex; gap: 8px; justify-content: center; }
.ig-sc__dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--bg-elev); box-shadow: 0 0 0 1px var(--border-strong); }
.ig-sc__dot.is-on { box-shadow: 0 0 0 2px var(--text); }
.ig-sc__row { display: flex; justify-content: center; }
.ig-sc__pick { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--r-pill); border: 1px solid var(--border-strong); font-weight: 600; }
.ig-sc__pick:hover { background: var(--hover); }
[data-bg="0"] { background: linear-gradient(160deg, #4f6bff, #7c5cff 50%, #e056b0); }
[data-bg="1"] { background: linear-gradient(160deg, #8a6a47, #2b1d10); }
[data-bg="2"] { background: linear-gradient(160deg, #2a4d7a, #0b1626); }
[data-bg="3"] { background: linear-gradient(160deg, #7d2634, #25080d); }
[data-bg="4"] { background: linear-gradient(160deg, #2f5a3b, #0c1a11); }
[data-bg="5"] { background: linear-gradient(160deg, #f1e9d6, #cdbd9a); }
.ig-sc__dot[data-bg] { background-clip: padding-box; }
.ig-sc__frame [data-bg="5"] ~ .ig-sc__ta, .ig-sc__preview[data-bg="5"] ~ .ig-sc__ta { color: #1a1a1a; text-shadow: none; }

/* ---------- Trình xem story ---------- */
.ig-sv { position: fixed; inset: 0; z-index: 3000; background: rgba(0, 0, 0, .94); display: grid; place-items: center; }
.ig-sv__stage { position: relative; width: min(440px, 100vw); height: min(100dvh, 800px); background: #000; border-radius: 12px; overflow: hidden; color: #fff; user-select: none; }
.ig-sv__bars { position: absolute; top: 8px; left: 10px; right: 10px; z-index: 3; display: flex; gap: 4px; }
.ig-sv__bar { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .35); overflow: hidden; }
.ig-sv__bar i { display: block; height: 100%; width: 0; background: #fff; }
.ig-sv__bar.is-done i { width: 100%; }
.ig-sv__bar:not(.is-done) i[style] { animation-name: ig-fill; animation-timing-function: linear; animation-fill-mode: forwards; }
.ig-sv__stage.is-paused .ig-sv__bar i { animation-play-state: paused; }
@keyframes ig-fill { from { width: 0; } to { width: 100%; } }
.ig-sv__head { position: absolute; top: 18px; left: 12px; right: 6px; z-index: 3; display: flex; align-items: center; gap: 8px; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.ig-sv__head small { opacity: .8; }
.ig-sv__sp { flex: 1; }
.ig-sv__btn { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; border-radius: 50%; }
.ig-sv__btn:hover { background: rgba(255, 255, 255, .15); }
.ig-sv__body { position: absolute; inset: 0; display: grid; place-items: center; }
.ig-sv__body img { width: 100%; height: 100%; object-fit: contain; background: #000; }
.ig-sv__text { position: absolute; left: 0; right: 0; padding: 0 28px; text-align: center; font-size: 26px; font-weight: 700; line-height: 1.3; word-break: break-word; }
.ig-sv__text.is-caption { top: auto; bottom: 64px; font-size: 16px; font-weight: 500; background: rgba(0, 0, 0, .5); margin: 0 14px; padding: 10px 12px; border-radius: 8px; left: 0; right: 0; }
.ig-sv__body[data-bg="5"] .ig-sv__text:not(.is-caption) { color: #1a1a1a; }
.ig-sv__zone { position: absolute; top: 64px; bottom: 56px; z-index: 2; background: transparent; }
.ig-sv__zone--prev { left: 0; width: 35%; }
.ig-sv__zone--next { right: 0; width: 65%; }
.ig-sv__foot { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; align-items: center; gap: 8px; padding: 18px 16px; background: linear-gradient(transparent, rgba(0, 0, 0, .65)); }
@media (max-width: 520px) { .ig-sv__stage { border-radius: 0; height: 100dvh; } }

/* ---------- Điện thoại ---------- */
@media (max-width: 820px) {
  .ig-col { padding: 10px 12px 24px; }
  .ig-col--wide { padding-top: 12px; }
  .ig-prof { gap: 18px; padding: 0 4px 18px; }
  .ig-prof__av { width: auto; }
  .ig-prof__row h2 { font-size: var(--fs-lg); }
  .ig-prof__stats { gap: 18px; }
  .ig-grid { gap: 2px; }
}

/* ---------- Thanh dưới kiểu Instagram (chế độ cổ điển) ---------- */
@media (max-width: 820px) {
  html:is([data-accent="classic"], [data-accent="tam"]) .app-rail { border-right: 0; border-top: 1px solid var(--border); }
  html:is([data-accent="classic"], [data-accent="tam"]) .app-rail__btn { color: var(--text-2); }
  html:is([data-accent="classic"], [data-accent="tam"]) .app-rail__btn.is-active { background: transparent; color: var(--text); }
  html:is([data-accent="classic"], [data-accent="tam"]) .app-rail__btn.is-active svg { stroke-width: 2.6; }
}
