/* Стили превью Instagram-аккаунта (рендерится js/preview.js). */

.ig {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    --ig-bg: #fff;
    --ig-text: #000;
    --ig-text-secondary: #262626;
    --ig-text-muted: #8e8e8e;
    --ig-border: #efefef;
    --ig-link: #00376b;
    --ig-btn-secondary-bg: #efefef;
    --ig-btn-secondary-text: #000;
    --ig-avatar-bg: #efefef;
    --ig-hl-ring: #c7c7c7;
    --ig-cell-bg: #fafafa;
    --ig-tab-active: #000;
    --ig-ic-color: #262626;
    color: var(--ig-text);
    background: var(--ig-bg);
}
.ig.ig-theme-dark {
    --ig-bg: #0d1015;
    --ig-text: #f5f5f5;
    --ig-text-secondary: #f5f5f5;
    --ig-text-muted: #a8a8a8;
    --ig-border: #262626;
    --ig-link: #e0f1ff;
    --ig-btn-secondary-bg: #363636;
    --ig-btn-secondary-text: #f5f5f5;
    --ig-avatar-bg: #262626;
    --ig-hl-ring: #545454;
    --ig-cell-bg: #181c22;
    --ig-tab-active: #f5f5f5;
    --ig-ic-color: #f5f5f5;
}
.ig * { box-sizing: border-box; }
.ig .ig-ic { color: var(--ig-ic-color); }

.ig-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Верхняя панель */
.ig-topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--ig-border);
    background: var(--ig-bg);
}
.ig-topbar-name { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 16px; }
.ig-topbar-icons { display: flex; gap: 14px; }

/* Шапка */
.ig-header {
    display: flex;
    align-items: flex-start;
    padding: 16px 16px 8px;
    gap: 20px;
}
.ig-header-right {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 4px;
}
.ig-avatar {
    width: 80px; height: 80px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
    background: var(--ig-avatar-bg);
}
.ig-avatar-fallback {
    display: flex; align-items: center; justify-content: center;
}
.ig-stats { display: flex; justify-content: space-around; text-align: center; width: 100%; }
.ig-stat { display: flex; flex-direction: column; }
.ig-stat-num { font-weight: 700; font-size: 16px; color: var(--ig-text); }
.ig-stat-label { font-size: 13px; color: var(--ig-text-secondary); }

/* Имя/био/ссылка */
.ig-bio { padding: 0 16px 8px; line-height: 1.4; }
.ig-fullname { font-weight: 600; display: flex; align-items: center; gap: 4px; font-size: 14px; line-height: 1.3; }
.ig-biotext { white-space: pre-line; color: var(--ig-text); }
.ig-link { color: var(--ig-link); text-decoration: none; font-weight: 600; display: inline-block; margin-top: 2px; }
.ig-verified { display: inline-flex; }

/* Кнопки */
.ig-actions { display: flex; gap: 6px; padding: 4px 16px 12px; }
.ig-btn {
    border: none; border-radius: 8px; font-weight: 600; font-size: 14px;
    padding: 7px 12px; cursor: default;
}
.ig-btn-primary { background: #0095f6; color: #fff; flex: 1 1 auto; }
.ig-btn-secondary { background: var(--ig-btn-secondary-bg); color: var(--ig-btn-secondary-text); flex: 1 1 auto; }
.ig-btn-icon { background: var(--ig-btn-secondary-bg); color: var(--ig-btn-secondary-text); padding: 7px 10px; display: flex; align-items: center; }
.ig-btn-icon .ig-ic { width: 16px; height: 16px; }

/* Хайлайтсы */
.ig-highlights {
    display: flex; gap: 14px;
    padding: 8px 16px 14px;
    overflow-x: auto;
    border-bottom: 1px solid var(--ig-border);
    scrollbar-width: none;
}
.ig-highlights::-webkit-scrollbar { display: none; }
.ig-hl { flex: 0 0 auto; width: 64px; text-align: center; }
.ig-hl-ring {
    width: 60px; height: 60px; border-radius: 50%;
    padding: 2px; margin: 0 auto;
    border: 1.5px solid var(--ig-hl-ring);
    display: flex; align-items: center; justify-content: center;
}
.ig-hl-cover { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--ig-avatar-bg); }
.ig-hl-title { font-size: 12px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ig-text); }

/* Табы */
.ig-tabs { display: flex; border-top: 1px solid var(--ig-border); }
.ig-tab { flex: 1 1 0; display: flex; align-items: center; justify-content: center; padding: 8px 0; color: var(--ig-text-muted); }
.ig-tab.active { color: var(--ig-tab-active); border-top: 1px solid var(--ig-tab-active); margin-top: -1px; }
.ig-tab .ig-ic { color: currentColor; }

/* Сетка */
.ig-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.ig-cell { position: relative; aspect-ratio: 1 / 1; background: var(--ig-cell-bg); overflow: hidden; }
.ig-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ig-cell-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: #c7c7c7; }
.ig-cell-badge { position: absolute; top: 6px; right: 6px; color: #fff; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.ig-cell-badge .ig-ic { width: 18px; height: 18px; color: #fff; }
.ig-cell-badge.ig-pin { color: #fff; }
.ig-empty { grid-column: 1 / -1; text-align: center; color: var(--ig-text-muted); padding: 40px 0; }

/* ---------- Просмотр историй ---------- */
.ig-story {
    position: absolute; inset: 0; z-index: 50;
    background: #000; display: flex; flex-direction: column;
}
.ig-story-bars { display: flex; gap: 4px; padding: 10px 10px 0; }
.ig-story-bar { flex: 1 1 0; height: 2.5px; background: rgba(255,255,255,.35); border-radius: 2px; overflow: hidden; }
.ig-story-bar-fill { height: 100%; width: 0; background: #fff; }
.ig-story-head { position: absolute; top: 0; left: 0; right: 0; z-index: 2; }
.ig-story-user { display: flex; align-items: center; gap: 8px; padding: 10px 12px; color: #fff; font-weight: 600; font-size: 13px; }
.ig-story-ava { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.ig-story-close { margin-left: auto; background: none; border: none; color: #fff; font-size: 28px; line-height: 1; cursor: pointer; }
.ig-story-stage { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ig-story-media { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
.ig-story-nav { position: absolute; top: 0; bottom: 0; width: 33%; z-index: 1; cursor: pointer; }
.ig-story-prev { left: 0; }
.ig-story-next { right: 0; width: 67%; }

/* ---------- Просмотр публикации ---------- */
.ig-post {
    position: absolute; inset: 0; z-index: 40;
    background: var(--ig-bg); display: flex; flex-direction: column;
    color: var(--ig-text);
}
.ig-post-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--ig-border); }
.ig-post-ava { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.ig-post-user { font-weight: 600; display: flex; align-items: center; gap: 4px; }
.ig-post-close { margin-left: auto; background: none; border: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--ig-text); }
.ig-post-media { position: relative; width: 100%; background: #000; aspect-ratio: 3 / 4; overflow: hidden; flex: 0 0 auto; }
.ig-post-media .ig-cell-empty { background: var(--ig-cell-bg); aspect-ratio: 3 / 4; }

/* Карусель */
.ig-car-track { display: flex; height: 100%; transition: transform .25s ease; }
.ig-car-slide { flex: 0 0 100%; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.ig-car-slide img, .ig-car-slide video { width: 100%; height: 100%; object-fit: cover; }
.ig-car-arrow {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(255,255,255,.8); color: #333;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; cursor: pointer; z-index: 2;
}
.ig-car-prev { left: 8px; }
.ig-car-next { right: 8px; }
.ig-car-counter {
    position: absolute; top: 8px; right: 8px; z-index: 2;
    background: rgba(0,0,0,.6); color: #fff;
    font-size: 12px; padding: 2px 8px; border-radius: 10px;
}
.ig-car-dots { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; justify-content: center; gap: 4px; z-index: 2; }
.ig-car-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.6); }
.ig-car-dot.active { background: #0095f6; }

/* Тело публикации */
.ig-post-body { padding: 8px 12px; overflow-y: auto; flex: 1 1 auto; }
.ig-post-actions { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.ig-post-actions-left { display: flex; gap: 14px; }
.ig-post-likes { font-weight: 600; margin: 4px 0; }
.ig-post-caption { margin: 2px 0; line-height: 1.4; }
.ig-post-comments { color: var(--ig-text-muted); margin-top: 6px; }

/* Панель темы (шапка редактора / публичная страница) */
.preview-theme-toggle .btn-check:checked + .btn-outline-secondary {
    background-color: #262626;
    border-color: #262626;
    color: #fff;
}
.public-page-toolbar {
    margin-bottom: 0.75rem;
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Публичная страница */
body.public-view {
    overflow-x: hidden;
}
.public-page {
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: #fafafa;
    padding: 0.75rem 20px 20px;
    box-sizing: border-box;
    overflow: hidden;
}
.public-page-inner {
    width: 100%;
    max-width: 390px;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
}
.public-page-toolbar {
    flex: 0 0 auto;
}
.public-phone-slot {
    flex: 1 1 0;
}
.public-page .phone-frame {
    margin: 0;
}
@media (max-width: 420px) {
    .public-page {
        padding: 12px;
    }
    .public-page-inner {
        max-width: 100%;
    }
}
