/* ─── Base ─────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface2: #1e1e1e;
    --border: #2a2a2a;
    --text: #e8e8e8;
    --text2: #888;
    --accent: #a855f7;
    --accent2: #7c3aed;
    --green: #22c55e;
    --red: #ef4444;
    --blue: #3b82f6;
    --radius: 12px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* ─── Header ──────────────────────────────────── */
.header {
    text-align: center;
    margin-bottom: 32px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
    position: relative;
}

/* Settings */
.settings-btn {
    position: absolute;
    right: 0;
    background: none;
    border: 1px solid var(--border);
    color: var(--text2);
    font-size: 18px;
    padding: 6px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.settings-btn:hover { color: var(--accent); border-color: var(--accent); }

.settings-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.settings-header h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.settings-close { background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; }
.settings-body { padding: 16px; }
.setting-item label { font-size: 13px; font-weight: 600; color: var(--text); display: block; margin-bottom: 6px; }
.setting-hint { font-size: 12px; color: var(--text2); margin-bottom: 8px; line-height: 1.5; }
.setting-hint code { background: var(--surface2); padding: 1px 5px; border-radius: 3px; font-size: 11px; color: var(--accent); }
.setting-input-row { display: flex; gap: 8px; }
.setting-input-row input {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    color: var(--text);
    font-size: 13px;
    font-family: monospace;
}
.setting-input-row input:focus { outline: none; border-color: var(--accent); }
.setting-status { font-size: 12px; margin-top: 8px; }

.logo-icon {
    font-size: 28px;
    color: var(--accent);
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text2);
    font-size: 15px;
}

/* ─── Search ──────────────────────────────────── */
.search-section {
    margin-bottom: 24px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    transition: border-color 0.2s;
}

.search-box:focus-within {
    border-color: var(--accent);
}

.at-sign {
    padding: 0 12px;
    color: var(--text2);
    font-size: 18px;
    font-weight: 600;
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 16px;
    padding: 12px 0;
    outline: none;
}

.search-box input::placeholder { color: #555; }

.search-box button {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    color: white;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.search-box button:hover { opacity: 0.9; }
.search-box button:disabled { opacity: 0.5; cursor: not-allowed; }

.search-options {
    display: flex;
    gap: 16px;
    margin-top: 10px;
    justify-content: center;
}

.search-options label {
    color: var(--text2);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.session-label input {
    width: 200px !important;
}

.search-options input,
.search-options select {
    width: 65px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
}

/* ─── Status ──────────────────────────────────── */
.status {
    text-align: center;
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
}

.status.loading {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text2);
}

.status.error {
    background: #1a0a0a;
    border: 1px solid #3a1515;
    color: var(--red);
}

.status.success {
    background: #0a1a0a;
    border: 1px solid #153a15;
    color: var(--green);
}

.btn-loader {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Profile Card ────────────────────────────── */
.profile-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.profile-header {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.profile-pic {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
    flex-shrink: 0;
}

.profile-info { flex: 1; }

.profile-info h2 {
    font-size: 20px;
    font-weight: 700;
}

.username {
    color: var(--text2);
    font-size: 14px;
}

.bio {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text);
    white-space: pre-line;
    line-height: 1.5;
}

.profile-stats {
    display: flex;
    gap: 32px;
    justify-content: center;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.stat { text-align: center; }

.stat-num {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    font-size: 12px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── Private Banner ─────────────────────────── */
.private-banner {
    text-align: center;
    padding: 40px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.private-banner .private-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.private-banner h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.private-banner p {
    font-size: 14px;
    color: var(--text2);
}

/* ─── Tabs ────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab {
    background: none;
    border: none;
    color: var(--text2);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab:hover { color: var(--text); }

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-count {
    background: var(--surface2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 4px;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Two Column Layout ─────────────────────── */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    align-items: start;
}
.main-left { min-width: 0; }
.main-right {
    position: sticky;
    top: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
.main-right::-webkit-scrollbar { width: 4px; }
.main-right::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.analytics-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.analytics-panel-header h3 { font-size: 16px; font-weight: 600; color: var(--text); }
.analytics-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--accent);
    color: white;
    font-weight: 500;
}
.empty-state-sm {
    color: var(--text2);
    font-size: 13px;
    text-align: center;
    padding: 30px 10px;
}

/* Analytics mini cards for side panel */
.analytics-mini-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}
.analytics-mini-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
}
.amc-value { font-size: 18px; font-weight: 700; color: var(--text); }
.amc-label { font-size: 11px; color: var(--text2); margin-top: 2px; }
.amc-icon { font-size: 14px; margin-bottom: 4px; }

/* Engagement bar */
.engagement-section { margin-bottom: 16px; }
.engagement-section h4 { font-size: 13px; color: var(--text2); margin-bottom: 8px; font-weight: 500; }
.engagement-rate-big {
    font-size: 36px;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    padding: 12px 0;
}
.engagement-rate-label { text-align: center; font-size: 12px; color: var(--text2); }

/* Content mix bar */
.mix-bar { height: 8px; border-radius: 4px; overflow: hidden; display: flex; margin: 8px 0; }
.mix-seg { height: 100%; min-width: 2px; }
.mix-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.mix-legend-item { font-size: 11px; color: var(--text2); display: flex; align-items: center; gap: 4px; }
.mix-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Top post card */
.top-post-mini {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
    cursor: pointer;
}
.top-post-mini:hover { border-color: var(--accent); }
.tpm-img { width: 50px; height: 50px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
.tpm-info { min-width: 0; flex: 1; }
.tpm-label { font-size: 11px; color: var(--accent); font-weight: 600; margin-bottom: 2px; }
.tpm-stat { font-size: 13px; color: var(--text); font-weight: 600; }
.tpm-caption { font-size: 11px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Deep fetch */
.deep-fetch-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.deep-fetch-btn {
    width: 100%;
    padding: 10px;
    background: var(--surface2);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: border-color 0.2s;
}
.deep-fetch-btn:hover { border-color: var(--accent); color: var(--accent); }
.df-icon { font-size: 16px; }
.deep-fetch-progress { margin-top: 10px; }
.df-bar-wrap { height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; }
.df-bar { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; width: 0%; }
.df-status { font-size: 12px; color: var(--text2); margin-top: 4px; display: block; }

/* Analytics section headers in panel */
.ap-section { margin-bottom: 16px; }
.ap-section h4 { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; font-weight: 600; }

/* Frequency */
.freq-value { font-size: 14px; color: var(--text); font-weight: 600; }
.freq-label { font-size: 11px; color: var(--text2); }

/* Analytics skeleton loader */
.analytics-skeleton { animation: fadeIn 0.3s ease; }
.skel-block {
    background: linear-gradient(110deg, var(--surface2) 30%, #252525 50%, var(--surface2) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}
.skel-eng { height: 80px; margin-bottom: 16px; border-radius: var(--radius); }
.skel-card { min-height: 70px; }
.skel-icon { width: 20px; height: 20px; border-radius: 50%; margin: 0 auto 6px; }
.skel-value { width: 50px; height: 18px; margin: 0 auto 4px; }
.skel-label { width: 70px; height: 10px; margin: 0 auto; }
.skel-bar { height: 8px; margin: 16px 0; }
.skel-post { height: 56px; margin-bottom: 10px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 900px) {
    .main-layout { grid-template-columns: 1fr; }
    .main-right { position: static; max-height: none; }
}

/* ─── Media Grid ──────────────────────────────── */
.media-grid {}

.media-grid-inner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.media-card {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 4px;
    cursor: pointer;
    background: var(--surface2);
}

.img-lazy-wrap {
    width: 100%;
    height: 100%;
    background: linear-gradient(110deg, var(--surface2) 30%, #252525 50%, var(--surface2) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.img-lazy-wrap.img-loaded {
    background: var(--surface2);
    animation: none;
}

.media-card img, .media-card .lazy-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s, opacity 0.5s ease;
}

.lazy-img {
    opacity: 0;
    filter: blur(10px);
    transform: scale(1.05);
}

.lazy-img.loaded {
    opacity: 1;
    filter: blur(0);
    transform: scale(1);
}

.skeleton-card {
    background: linear-gradient(110deg, var(--surface2) 30%, #252525 50%, var(--surface2) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.media-card:hover img {
    transform: scale(1.05);
    opacity: 0.7;
}

.media-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    display: flex;
    gap: 12px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s;
}

.media-card:hover .media-overlay { opacity: 1; }

.media-overlay span {
    display: flex;
    align-items: center;
    gap: 4px;
    color: white;
    font-weight: 600;
}

.media-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.media-badge.reel { background: var(--accent); }
.media-badge.video { background: var(--blue); }
.media-badge.carousel { background: var(--green); }

/* ─── Analytics ──────────────────────────────── */
.analytics-loading {
    text-align: center;
    padding: 60px 20px;
}
.al-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.al-subtitle {
    font-size: 14px;
    color: var(--text2);
    margin-bottom: 16px;
}
.al-timer {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 16px;
    font-variant-numeric: tabular-nums;
}
.al-hint {
    font-size: 12px;
    color: #555;
    line-height: 1.6;
}

/* Deep Analytics progress */
.deep-progress-wrap { text-align: center; padding: 40px 20px; }
.dp-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 20px; }
.dp-bar-wrap { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.dp-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); border-radius: 3px; transition: width 0.5s ease; width: 0%; }
.dp-status { font-size: 14px; color: var(--text); margin-bottom: 8px; }
.dp-timer { font-size: 24px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

.analytics-header { margin-bottom: 20px; }
.analytics-refresh { margin-top: 10px; display: flex; align-items: center; gap: 12px; }
.analytics-refresh-hint { font-size: 12px; color: var(--text2); }
.analytics-header h3 { font-size: 18px; font-weight: 600; color: var(--text); }
.analytics-subtitle {
    font-size: 13px;
    color: var(--text2);
    margin-top: 4px;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: inline-block;
    margin-top: 8px;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.analytics-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.ac-icon { font-size: 24px; margin-bottom: 8px; }
.ac-value { font-size: 28px; font-weight: 700; color: var(--text); }
.ac-label { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

.analytics-totals {
    display: flex;
    justify-content: space-around;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}

.at-item { text-align: center; }
.at-val { display: block; font-size: 18px; font-weight: 700; color: var(--text); }
.at-lbl { font-size: 11px; color: var(--text2); text-transform: uppercase; }

.analytics-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.analytics-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.content-mix-bar {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 12px;
}

.cmb-segment { min-width: 4px; transition: width 0.3s; }
.cmb-segment:first-child { border-radius: 6px 0 0 6px; }
.cmb-segment:last-child { border-radius: 0 6px 6px 0; }

.cmb-legend { display: flex; flex-wrap: wrap; gap: 16px; }
.cmb-legend-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text2); }
.cmb-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.top-posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.top-post-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.tp-header {
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tp-media { aspect-ratio: 1; overflow: hidden; }
.tp-media img { width: 100%; height: 100%; object-fit: cover; }
.tp-no-img { display: flex; align-items: center; justify-content: center; height: 100%; color: #555; font-size: 13px; }

.tp-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
}

.tp-metric { font-size: 15px; font-weight: 700; color: var(--text); }
.tp-type { font-size: 10px; background: var(--surface2); padding: 2px 8px; border-radius: 4px; color: var(--text2); }

.tp-caption {
    padding: 0 12px 10px;
    font-size: 12px;
    color: var(--text2);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .analytics-grid { grid-template-columns: repeat(2, 1fr); }
    .top-posts-grid { grid-template-columns: 1fr; }
    .analytics-totals { flex-wrap: wrap; gap: 12px; }
}

/* ─── Pagination ─────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pag-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pag-btn:hover:not(:disabled) { background: var(--border); }
.pag-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.pag-num {
    background: none;
    border: 1px solid transparent;
    color: var(--text2);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pag-num:hover { background: var(--surface2); color: var(--text); }

.pag-num.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.pag-current {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    padding: 0 8px;
}

.pag-dots {
    color: var(--text2);
    padding: 0 4px;
    font-size: 14px;
}

.pag-info {
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: var(--text2);
    margin-top: 8px;
}

/* ─── Carousel ───────────────────────────────── */
.carousel-count-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 5;
    line-height: 1;
}

.carousel-nav:hover { background: rgba(0,0,0,0.85); }
.carousel-prev { left: 10px; }
.carousel-next { right: 10px; }

.carousel-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    z-index: 5;
}

.carousel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    transition: background 0.2s;
}

.carousel-dot.active { background: white; }

.carousel-counter {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    z-index: 5;
}

/* ─── Modal ───────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.open { display: flex; }

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text2);
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
}

.modal-close:hover { color: var(--text); }

.modal-media {
    width: 100%;
    background: black;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.media-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.modal-media img, .modal-media video {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
}

.modal-info {
    padding: 20px;
}

.modal-info .caption {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 12px;
    white-space: pre-line;
}

.modal-info .meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 8px;
}

.modal-info .meta-row strong {
    color: var(--text);
}

.modal-info .hashtags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.modal-info .hashtag {
    background: var(--surface2);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.modal-info .url-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.modal-info .url-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 11px;
    color: var(--text2);
    word-break: break-all;
    margin-top: 6px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.modal-info .url-box:hover {
    border-color: var(--accent);
}

.modal-info .url-label {
    font-size: 11px;
    color: var(--text2);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 8px;
}

.modal-info .expiry {
    font-size: 11px;
    color: var(--text2);
    margin-top: 4px;
}

.expiry .active { color: var(--green); }
.expiry .expired { color: var(--red); }

/* ─── JSON ────────────────────────────────────── */
.json-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.btn-small {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-small:hover { background: var(--border); }

.json-output {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-size: 12px;
    line-height: 1.5;
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
    color: var(--text2);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* ─── History ─────────────────────────────────── */
.history-section {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.history-section h3 {
    font-size: 16px;
    color: var(--text2);
    margin-bottom: 12px;
    font-weight: 600;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s;
    font-size: 14px;
}

.history-item:hover { border-color: var(--accent); }

.history-item .hi-user {
    font-weight: 600;
    color: var(--text);
}

.history-item .hi-meta {
    color: var(--text2);
    font-size: 12px;
    display: flex;
    gap: 12px;
}

/* ─── Responsive ──────────────────────────────── */
@media (max-width: 600px) {
    .media-grid-inner { grid-template-columns: repeat(3, 1fr); }
    .profile-header { flex-direction: column; align-items: center; text-align: center; }
    .profile-stats { gap: 20px; }
    .search-box { flex-direction: column; gap: 8px; padding: 12px; }
    .search-box button { width: 100%; }
    .at-sign { display: none; }
}

/* ─── Empty state ─────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text2);
}

.empty-state .icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--green);
    color: black;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    z-index: 2000;
    animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
