/* ============================================
   کافی‌نت آینده — Stylesheet V10 (Final Clean)
   ============================================ */

/* ============ 1. VARIABLES & BASE ============ */
:root {
    --dark-navy: #101728;
    --purple: #6357EE;
    --light-purple: #EFEDFF;
    --turquoise: #18BFA1;
    --pink: #ED526C;
    --bg: #F7F8FB;
    --white: #FFFFFF;
    --text-main: #182034;
    --text-secondary: #8993A4;
    --border: #ECEEF4;

    --r-icon: 50%;
    --r-btn: 10px;
    --r-card: 18px;

    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-xl: 24px;

    --sh-sm: 0 2px 8px rgba(16, 23, 40, 0.04);
    --sh-md: 0 4px 20px rgba(16, 23, 40, 0.06);
    --sh-lg: 0 8px 30px rgba(16, 23, 40, 0.08);

    --header-h: 70px;
    --nav-h: 64px;
    --max-w: 570px;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: 'Estedad', sans-serif;
    background: var(--bg);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }

/* ============ 2. APP & VIEWS ============ */
.app {
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    background: var(--bg);
    min-height: 100vh;
    position: relative;
    box-shadow: 0 0 60px rgba(16, 23, 40, 0.06);
    padding-bottom: calc(var(--nav-h) + 16px);
    overflow-x: hidden;
}

.main {
    padding-top: var(--header-h);
}

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.svg-sprite { display: none; }

/* ============ 3. HEADER ============ */
.header {
    height: var(--header-h);
    background: var(--dark-navy);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: fixed; 
    top: 0;
    left: 50%; 
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--max-w); 
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); 
}
.header-right { display: flex; align-items: center; gap: 10px; }
.logo {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--purple), var(--turquoise));
    border-radius: var(--r-btn);
    display: flex; align-items: center; justify-content: center;
    color: #fff; flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99, 87, 238, 0.25);
    overflow: hidden;
    font-weight: 700;
}
.logo img { width: 100%; height: 100%; object-fit: cover; }
.logo .icon { width: 24px; height: 24px; stroke: #fff; stroke-width: 2; }
.header-titles { display: flex; flex-direction: column; }
.header-title { color: #fff; font-size: 15px; font-weight: 700; line-height: 1.2; }
.header-subtitle { color: rgba(255, 255, 255, 0.45); font-size: 10px; font-family: 'Vazirmatn', sans-serif; margin-top: 2px; }
.header-left { display: flex; align-items: center; gap: 6px; }

.header-copyright {
    display: block;
    font-size: 8px;
    color: rgba(255, 255, 255, 0.35); /* خطای تایپی اینجا برطرف شد */
    margin-top: 2px;
    font-family: 'Vazirmatn', sans-serif;
}

.channel-header { background: var(--dark-navy); }
.channel-header-info { display: flex; flex-direction: column; margin-right: auto; margin-left: auto; text-align: center; }

/* ============ 4. BUTTONS ============ */
.btn-icon {
    width: 38px; height: 38px;
    border: none; background: rgba(255, 255, 255, 0.08);
    border-radius: var(--r-btn);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: #fff;
    transition: all 0.2s ease; position: relative; flex-shrink: 0;
    text-decoration: none;
}
.btn-icon:hover { background: rgba(255, 255, 255, 0.15); }
.btn-icon:active { transform: scale(0.92); }
.badge {
    position: absolute; top: -2px; left: -2px;
    min-width: 18px; height: 18px;
    background: var(--pink); color: #fff;
    border-radius: 9px; font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--dark-navy); padding: 0 4px;
    font-family: 'Vazirmatn', sans-serif;
}

/* ============ 5. STORIES ============ */
.stories { padding: 20px 0 16px; background: var(--bg); }
.section-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 0 16px; margin-bottom: 14px; }
.section-title-group { display: flex; flex-direction: column; gap: 2px; }
.section-title { font-size: 16px; font-weight: 700; }
.section-subtitle { font-size: 11px; color: var(--text-secondary); font-family: 'Vazirmatn', sans-serif; }
.section-channel { font-size: 11px; color: var(--purple); font-family: 'Vazirmatn', sans-serif; }

.stories-scroll { display: flex; gap: 14px; overflow-x: auto; padding: 4px 16px 8px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.stories-scroll::-webkit-scrollbar { display: none; }
.story-item { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; width: 72px; background: none; border: none; cursor: pointer; font-family: 'Estedad', sans-serif; scroll-snap-align: start; }

.story-circle {
    width: 66px; height: 66px;
    border-radius: var(--r-icon);
    padding: 2px; 
    background: #18BFA1; 
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: transform 0.2s ease;
}
.story-item:active .story-circle { transform: scale(0.93); }

.story-inner-avatar {
    width: 100%; height: 100%;
    border-radius: var(--r-icon);
    background: #fff; 
    padding: 2px; 
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.story-inner-avatar img, .story-inner-avatar svg {
    width: 100%; height: 100%;
    border-radius: var(--r-icon);
    object-fit: cover;
}
.story-inner-avatar .icon { stroke: var(--text-main); stroke-width: 1.5; }
.story-name { font-size: 12px; font-weight: 600; line-height: 1.2; max-width: 72px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ 6. FEED & MASONRY & BLE-STYLE CHANNEL LIST ============ */
.feed { padding: 8px 16px 20px; }
.posts { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }

.masonry-grid.layout-masonry { padding: 0; column-count: 2; column-gap: 1.5px; }
.masonry-grid.layout-masonry .masonry-tile { break-inside: avoid; margin-bottom: 1.5px; border-radius: 0; background: #000; }
.masonry-grid.layout-masonry .tile-img-bg { display: none; }
.masonry-grid.layout-masonry .tile-img { width: 100%; height: auto; display: block; object-fit: cover; }

.masonry-grid.layout-grid-2 { padding: 1.5px; display: grid; grid-template-columns: 1fr 1fr; gap: 1.5px; }
.masonry-grid.layout-grid-2 .masonry-tile { margin-bottom: 0; border-radius: 0; aspect-ratio: 1; position: relative; overflow: hidden; background: #000; }
.masonry-grid.layout-grid-2 .tile-img-bg { position: absolute; inset: 0; background-size: cover; background-position: center; filter: blur(15px) brightness(0.6); transform: scale(1.2); z-index: 1; }
.masonry-grid.layout-grid-2 .tile-img { position: relative; z-index: 2; width: 100%; height: 100%; object-fit: contain; }

.masonry-grid.layout-grid-3 { padding: 1.5px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5px; }
.masonry-grid.layout-grid-3 .masonry-tile { margin-bottom: 0; border-radius: 0; aspect-ratio: 1; position: relative; overflow: hidden; background: #000; }
.masonry-grid.layout-grid-3 .tile-img-bg { position: absolute; inset: 0; background-size: cover; background-position: center; filter: blur(15px) brightness(0.6); transform: scale(1.2); z-index: 1; }
.masonry-grid.layout-grid-3 .tile-img { position: relative; z-index: 2; width: 100%; height: 100%; object-fit: contain; }
.masonry-grid.layout-grid-3 .tile-body { padding: 8px; z-index: 3; position: absolute; bottom: 0; background: linear-gradient(transparent, rgba(0,0,0,0.8)); width: 100%; }
.masonry-grid.layout-grid-3 .tile-title { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.masonry-grid.layout-grid-3 .tile-channel { font-size: 9px; color: #ccc; }

.masonry-grid.layout-list { padding: 8px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.masonry-grid.layout-list .masonry-tile { display: flex; align-items: center; margin-bottom: 0; border-radius: var(--r-card); box-shadow: var(--sh-sm); overflow: hidden; }
.masonry-grid.layout-list .tile-img-bg { display: none; }
.masonry-grid.layout-list .tile-img { width: 100px; height: 100px; flex-shrink: 0; aspect-ratio: auto; object-fit: cover; }
.masonry-grid.layout-list .tile-body { padding: 12px; }
.masonry-grid.layout-list .tile-title { font-size: 14px; white-space: normal; }

.masonry-grid.hide-text .tile-body { display: none !important; }

@keyframes highlightPost {
    0% { box-shadow: 0 0 0 0 rgba(99, 87, 238, 0); border-color: var(--border); }
    20% { box-shadow: 0 0 20px 4px rgba(99, 87, 238, 0.3); border-color: var(--primary); }
    100% { box-shadow: 0 0 0 0 rgba(99, 87, 238, 0); border-color: var(--border); }
}
.post.highlight { animation: highlightPost 2s ease; }

.channel-row { 
    display: flex; align-items: center; padding: 14px 16px; 
    border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.2s; 
    background: var(--white); border-radius: var(--r-card); margin-bottom: 8px; box-shadow: var(--sh-sm); 
    text-decoration: none; color: var(--text-main);
}
.channel-row:hover { background: var(--bg); }
.channel-row:active { background: var(--border); }

.ch-avatar {
    width: 52px; height: 52px;
    border-radius: var(--r-icon);
    flex-shrink: 0; margin-left: 14px;
    position: relative;
    padding: 2px; 
    background: var(--text-main); 
    display: flex; align-items: center; justify-content: center;
}
.ch-avatar.has-story { background: #18BFA1; }

.ch-inner-avatar {
    width: 100%; height: 100%; border-radius: var(--r-icon); overflow: hidden;
    background: #fff; padding: 1.5px; 
    display: flex; align-items: center; justify-content: center;
}
.ch-inner-avatar img, .ch-inner-avatar svg {
    width: 100%; height: 100%;
    border-radius: var(--r-icon);
    object-fit: cover;
}

.ch-info { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ch-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ch-name { 
    font-size: 14px; 
    font-weight: 700; 
    color: var(--text-main); 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    flex: 1; 
    min-width: 0; 
}
.ch-date { 
    font-size: 11px; 
    color: var(--text-secondary); 
    font-family: 'Vazirmatn', sans-serif; 
    flex-shrink: 0; 
}
.ch-last-msg { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }

/* ============ 7. POST LAYOUT ============ */
.post {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    padding: 0; 
    box-shadow: var(--sh-sm);
    overflow: hidden; 
    margin-bottom: 16px;
}
.post-important { border-color: rgba(237, 82, 108, 0.2); }

.post-top-bar { display: flex; justify-content: flex-start; padding: 10px 14px; }
.post-top-bar .btn-share-post { background: transparent; color: var(--text-secondary); width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.post-top-bar .btn-share-post:hover { background: var(--bg); color: var(--purple); }
.post-top-bar .btn-share-post:active { transform: scale(0.9); }
.post-img {
    width: 100%;
    max-width: 100%;
    height: auto; 
    display: block;
    background: var(--bg);
}

.post-content { padding: 14px 16px 8px; }
.post-author-line { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.post-author-line .avatar { width: 32px; height: 32px; border-radius: var(--r-btn); background: linear-gradient(135deg, var(--purple), var(--turquoise)); display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.post-author-line .avatar img { width: 100%; height: 100%; object-fit: cover; }
.post-author-line .avatar .icon { width: 18px; height: 18px; stroke: #fff; stroke-width: 2; }
.post-title { font-size: 15px; font-weight: 700; color: var(--text-main); line-height: 1.4; margin: 0; }
.post-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.8; margin: 0; }

.badge-important { display: inline-flex; align-items: center; gap: 2px; background: rgba(237, 82, 108, 0.1); color: var(--pink); font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: var(--r-btn); margin-bottom: 10px; font-family: 'Vazirmatn', sans-serif; }

.post-footer { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); }
.post-time-footer { font-size: 11px; color: var(--text-secondary); font-family: 'Vazirmatn', sans-serif; }
.btn-action-footer { display: flex; align-items: center; gap: 6px; border: none; background: transparent; cursor: pointer; font-family: 'Estedad', sans-serif; font-weight: 600; color: var(--text-secondary); padding: 6px 12px; border-radius: var(--r-btn); font-size: 13px; transition: all 0.2s; }
.btn-action-footer:active { transform: scale(0.92); }
.btn-action-footer.liked { color: var(--pink); }
.btn-action-footer.liked svg { fill: var(--pink); stroke: var(--pink); }
@keyframes likePulse { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 70% { transform: scale(0.9); } 100% { transform: scale(1); } }
.btn-like.animating svg { animation: likePulse 0.4s ease; }

/* ============ 8. CHANNEL DETAIL ============ */
.channel-banner { margin: 16px; padding: 20px; background: var(--white); border-radius: var(--r-card); display: flex; align-items: center; gap: 16px; border: 1px solid var(--border); box-shadow: var(--sh-sm); }
.channel-banner-icon { width: 60px; height: 60px; border-radius: var(--r-card); display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--purple), var(--turquoise)); flex-shrink: 0; }
.channel-banner-icon .icon { width: 32px; height: 32px; stroke: #fff; stroke-width: 1.8; }
.channel-banner-text h2 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.channel-banner-text p { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; line-height: 1.5; }
.channel-banner-text span { font-size: 11px; color: var(--purple); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; font-family: 'Vazirmatn', sans-serif; }

/* ============ 9. CONNECTIONS GRID ============ */
.connections-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 8px 16px 20px;
}
@media (min-width: 480px) {
    .connections-grid { grid-template-columns: 1fr 1fr; }
}

.connection-card {
    background: var(--white);
    border-radius: var(--r-card);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: var(--text-main);
    box-shadow: var(--sh-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.connection-card:hover { transform: translateY(-3px); box-shadow: var(--sh-md); }
.connection-card:active { transform: scale(0.98); }

.conn-icon-wrap {
    width: 52px; height: 52px;
    border-radius: var(--r-icon);
    background: var(--bg);
    padding: 3px; 
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.conn-icon-wrap img, .conn-icon-wrap svg {
    width: 100%; height: 100%;
    border-radius: var(--r-icon);
    object-fit: cover;
}

.conn-info { flex: 1; min-width: 0; }
.conn-title { font-size: 15px; font-weight: 700; color: var(--text-main); margin: 0 0 4px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn-desc { font-size: 12px; color: var(--text-secondary); margin: 0; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.conn-arrow { width: 32px; height: 32px; border-radius: var(--r-btn); background: var(--bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.conn-arrow .icon { width: 16px; height: 16px; color: var(--text-secondary); }

/* ============ 10. BOTTOM NAVIGATION ============ */
.bottom-nav {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: var(--max-w);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-around;
    z-index: 90; box-shadow: 0 -2px 20px rgba(16, 23, 40, 0.05);
}
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 100%; width: 20%; padding: 8px 0; position: relative; background: none; border: none; cursor: pointer; color: var(--text-secondary); transition: all 0.25s ease; font-family: 'Estedad', sans-serif; text-decoration: none; }
.nav-item .icon { width: 24px; height: 24px; stroke-width: 1.8; transition: transform 0.2s ease; }
.nav-label { font-size: 10px; font-weight: 600; line-height: 1; transition: color 0.2s ease; }
.nav-item.active { color: var(--purple); }
.nav-item.active .icon { transform: translateY(-2px) scale(1.1); }
.nav-item.active::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 32px; height: 3px; background: var(--purple); border-radius: 0 0 4px 4px; }
.nav-badge { position: absolute; top: 8px; left: 50%; margin-left: 8px; min-width: 16px; height: 16px; background: var(--pink); color: #fff; border-radius: 8px; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; font-family: 'Vazirmatn', sans-serif; border: 2px solid #fff; }

.nav-item-center { position: relative; }
.nav-center-btn { width: 46px; height: 46px; background: linear-gradient(135deg, var(--purple), #8B7FFF); border-radius: var(--r-card); display: flex; align-items: center; justify-content: center; margin-top: -20px; box-shadow: 0 6px 16px rgba(99, 87, 238, 0.35); transition: all 0.2s ease; }
.nav-item-center.active .nav-center-btn { background: linear-gradient(135deg, var(--turquoise), var(--purple)); transform: scale(1.05); }
.nav-item-center .nav-label { margin-top: 4px; }
.nav-center-btn .icon { width: 24px; height: 24px; stroke: #fff; stroke-width: 2; }

/* ============ 11. NOTIFICATION PANEL ============ */
.notif-overlay { position: fixed; inset: 0; background: rgba(16, 23, 40, 0.45); backdrop-filter: blur(2px); z-index: 140; opacity: 0; visibility: hidden; transition: all 0.3s ease; }
.notif-overlay.active { opacity: 1; visibility: visible; }
.notif-panel { position: fixed; top: var(--header-h); left: 50%; transform: translateX(-50%) translateY(-12px); width: 100%; max-width: var(--max-w); background: var(--white); border-radius: 0 0 var(--r-lg) var(--r-lg); box-shadow: 0 12px 40px rgba(16, 23, 40, 0.15); z-index: 141; opacity: 0; visibility: hidden; transition: all 0.3s ease; max-height: 70vh; overflow-y: auto; }
.notif-panel.active { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
.notif-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.notif-title-group { display: flex; flex-direction: column; gap: 2px; }
.notif-panel-title { font-size: 16px; font-weight: 700; }
.notif-count { font-size: 11px; color: var(--purple); font-family: 'Vazirmatn', sans-serif; }
.notif-panel .btn-icon { background: var(--bg); color: var(--text-secondary); }
.notif-panel .btn-icon:hover { background: var(--border); }
.notif-panel .btn-icon .icon { width: 20px; height: 20px; }
.notif-list { padding: 8px 0; }
.notif-item { display: flex; align-items: flex-start; gap: 10px; padding: 12px 18px; position: relative; cursor: pointer; transition: background 0.2s ease; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--light-purple); }
.notif-item.unread::before { content: ''; position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 60%; background: var(--purple); border-radius: 3px 0 0 3px; }
.notif-content { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.notif-text { font-size: 13px; font-weight: 600; line-height: 1.4; }
.notif-sub { font-size: 11px; color: var(--text-secondary); font-family: 'Vazirmatn', sans-serif; }

/* ============ 12. STORY VIEWER V4 ============ */
.story-viewer {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden;
    transition: all 0.35s ease;
    padding: 0; 
}
.story-viewer.active { opacity: 1; visibility: visible; }
.story-viewer-overlay {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.95); 
}

.story-card {
    position: relative;
    width: 100%; height: 100%; 
    max-width: 100%; max-height: 100%;
    background: #000;
    border-radius: 0; 
    overflow: hidden;
    display: flex; justify-content: center; align-items: center;
    box-shadow: none;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}
.story-viewer.active .story-card { transform: scale(1); }

@media (min-width: 600px) {
    .story-viewer { padding: 20px; }
    .story-card {
        width: 420px; height: 90vh;
        max-width: 420px; max-height: 90vh;
        border-radius: 24px;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    }
}

.story-bg {
    position: absolute; inset: 0;
    background-size: cover; background-position: center;
    filter: blur(40px); transform: scale(1.2);
    opacity: 0.6;
}
.story-fg {
    position: relative; z-index: 2;
    max-width: 100%; max-height: 100%;
    object-fit: contain; 
}

.story-tap-zone {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 45px;
    height: 70px;
    z-index: 15;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background 0.2s ease;
}
.story-tap-zone:hover { background: rgba(255, 255, 255, 0.3); }
.story-tap-zone:active { transform: translateY(-50%) scale(0.9); }

.story-tap-zone.left { left: 0; border-radius: 0 35px 35px 0; justify-content: flex-start; padding-right: 8px; }
.story-tap-zone.right { right: 0; border-radius: 35px 0 0 35px; justify-content: flex-end; padding-left: 8px; }

.story-viewer-close { position: absolute; top: 25px; left: 15px; width: 36px; height: 36px; border: none; background: rgba(0,0,0,0.4); border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #fff; z-index: 20; }
.story-viewer-close .icon { width: 20px; height: 20px; }

.story-segments { position: absolute; top: 15px; right: 15px; left: 15px; display: flex; gap: 4px; z-index: 20; }
.story-segment { flex: 1; height: 3px; background: rgba(255, 255, 255, 0.3); border-radius: 3px; overflow: hidden; }
.story-segment-fill { height: 100%; width: 0%; background: #fff; border-radius: 3px; transition: width 0.1s linear; }

.story-viewer-title { position: absolute; bottom: 40px; right: 0; left: 0; text-align: center; color: #fff; font-size: 18px; z-index: 5; text-shadow: 0 2px 10px rgba(0,0,0,0.8); padding: 0 30px; }

.story-channel-tag { position: absolute; bottom: 15px; right: 15px; z-index: 5; color: rgba(255,255,255,0.8); font-size: 11px; background: rgba(0,0,0,0.5); padding: 5px 12px; border-radius: 20px; display: none; }
.story-channel-tag.show { display: block; }

.story-share-btn { position: absolute; bottom: 15px; left: 15px; z-index: 5; color: rgba(255,255,255,0.8); background: rgba(0,0,0,0.5); border: none; width: 36px; height: 36px; border-radius: 50%; display: none; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; }
.story-share-btn.show { display: flex; }
.story-share-btn:active { transform: scale(0.9); background: rgba(255,255,255,0.2); }
.story-share-btn .icon { width: 18px; height: 18px; }

.story-mute-btn { position: absolute; bottom: 15px; left: 60px; z-index: 5; color: rgba(255,255,255,0.8); background: rgba(0,0,0,0.5); border: none; width: 36px; height: 36px; border-radius: 50%; display: none; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; }
.story-mute-btn.show { display: flex; }
.story-mute-btn:active { transform: scale(0.9); background: rgba(255,255,255,0.2); }
.story-mute-btn .icon { width: 18px; height: 18px; }

#storyIcon, #storyDesc, .story-viewer-next, .story-viewer-progress, .progress-bar { display: none !important; }

/* ============ 13. TOAST ============ */
.toast-container { position: fixed; bottom: calc(var(--nav-h) + 24px); left: 50%; transform: translateX(-50%); z-index: 300; width: 90%; max-width: 500px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--dark-navy); color: #fff; padding: 12px 22px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500; box-shadow: 0 8px 30px rgba(16, 23, 40, 0.25); opacity: 0; transform: translateY(20px); transition: all 0.35s cubic-bezier(0.2, 0.8, 0.3, 1); pointer-events: auto; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateY(0); }

/* ============ 14. SVG ICON SYSTEM ============ */
svg.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: inline-block; vertical-align: middle; flex-shrink: 0; }
svg.icon.fill-only { fill: currentColor; stroke: none; }

/* ============ 15. UI ENHANCEMENTS ============ */
@keyframes postFadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
.post { animation: postFadeIn 0.4s ease forwards; }

.skeleton-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px; }
.skel-line { height: 12px; background: linear-gradient(90deg, #f0f2f5 25%, #e4e7eb 50%, #f0f2f5 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 6px; margin-bottom: 10px; }
.skel-avatar { width: 40px; height: 40px; border-radius: 12px; }
.skel-flex { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.skel-title { height: 18px; width: 80%; margin-bottom: 16px; }
.skel-img { width: 100%; height: 180px; border-radius: var(--r-md); margin-bottom: 16px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============ 16. RESPONSIVE ============ */
@media (max-width: 380px) {
    .post-title { font-size: 14px; }
    .post-desc { font-size: 12px; }
    .nav-label { font-size: 9px; }
    .nav-item { padding: 8px 4px; }
    .story-item { width: 64px; }
    .story-circle { width: 56px; height: 56px; }
}
@media (min-width: 571px) {
    body { background: linear-gradient(135deg, #E8EAF3, #EDE8F5); }
}

table {
    max-width: 100%;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============ FLOATING NOTIFICATION ============ */
.floating-notif {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 14px 18px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    display: flex;
    gap: 12px;
    align-items: center;
    z-index: 95;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.4s;
    border-right: 5px solid var(--purple);
    max-width: 90%;
    width: 400px;
    opacity: 0;
}
.floating-notif.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.fn-content { display: flex; flex-direction: column; flex: 1; }
.fn-content strong { color: var(--text-main); font-size: 15px; margin-bottom: 4px; font-weight: 700; }
.fn-content span { color: var(--text-secondary); font-size: 13px; line-height: 1.4; }
.fn-close { background: rgba(0,0,0,0.05); border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; padding: 0; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: 0.2s; flex-shrink: 0; }
.fn-close:hover { background: rgba(0,0,0,0.1); color: var(--text-main); }

/* ============ RICH TEXT EDITOR STYLES IN POST ============ */
.post-desc h2, .post-desc h3 { color: var(--text-main); font-weight: 800; margin: 15px 0 8px; line-height: 1.4; }
.post-desc h2 { font-size: 19px; }
.post-desc h3 { font-size: 16px; }
.post-desc b, .post-desc strong { font-weight: 700; color: var(--text-main); }
.post-desc i, .post-desc em { font-style: italic; }
.post-desc u { text-decoration: underline; text-underline-offset: 2px; }
.post-desc s, .post-desc strike { text-decoration: line-through; opacity: 0.8; }
.post-desc ul, .post-desc ol { padding-right: 25px; margin: 12px 0; }
.post-desc ul { list-style: disc; }
.post-desc ol { list-style: decimal; }
.post-desc li { margin-bottom: 8px; line-height: 1.7; }
.post-desc p { margin-bottom: 12px; }
.post-desc a { color: var(--purple); text-decoration: underline; font-weight: 600; word-break: break-word; }
.post-desc a:hover { opacity: 0.8; }
.post-desc blockquote { border-right: 4px solid var(--purple); padding: 10px 15px; margin: 15px 0; background: var(--bg); border-radius: 0 8px 8px 0; color: var(--text-secondary); font-style: italic; }
.post-desc span { display: inline; }

/* ============ TOOLS & EMBED VIEW (Final Fix) ============ */

/* تنظیمات لیست ابزارها */
#view-tools {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--max-w);
    height: 100vh;
    background: var(--bg);
    z-index: 50;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: none !important; /* حل مشکل ورود از راست */
}
#view-tools.active { display: flex; }

#view-tools .header {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    width: 100%;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

#view-tools .main {
    flex: 1;
    overflow-y: auto;
    padding: 16px !important;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    box-sizing: border-box;
}

/* تنظیمات صفحه باز شدن سایت مقصد (Iframe) */
#view-embed {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--max-w);
    height: 100vh;
    background: #fff;
    z-index: 50;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: none !important; /* حل مشکل ورود از راست */
}
#view-embed.active { display: flex; }

#view-embed .header {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    width: 100%;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

#view-embed .main {
    flex: 1;
    overflow: hidden;
    padding: 0 !important;
    /* حل مشکل پنهان شدن دکمه‌های سایت مقصد زیر فوتر */
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)) !important;
    display: flex !important;
    flex-direction: column;
    min-height: 0;
    box-sizing: border-box;
}

#embedFrame {
    width: 100%;
    height: 100%;
    border: none;
    flex: 1;
    background: #fff;
    display: block;
}

/* ============ TOOLS GRID FINAL FIX ============ */
#toolsContainer {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
    box-sizing: border-box;
}
@media (min-width: 480px) {
    #toolsContainer { 
        grid-template-columns: 1fr 1fr; 
    }
}