/* ===== CSS Custom Properties (Design Tokens) ===== */
:root {
    /* Light Theme (Default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #e8e8ed;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #86868b;
    --border-color: #d2d2d7;
    --accent-color: #007aff;
    --danger-color: #ff3b30;
    --success-color: #34c759;
    --like-color: #ff2d55;
    --save-color: #007aff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #6e6e73;
    --border-color: #38383a;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ===== Reset & Base Styles ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

button {
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
    color: inherit;
}

input {
    font-family: inherit;
    border: none;
    outline: none;
}

img {
    max-width: 100%;
    display: block;
}

/* ===== App Layout ===== */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 60px;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    border-radius: 0 0 16px 16px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    transition: background-color var(--transition-normal);
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .header {
        width: 60%;
    }
}

.header-content {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 100%;
}

.logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ===== Main Content ===== */
.main {
    flex: 1;
    overflow-y: auto;
    height: calc(100vh - 60px - 60px);
    padding-bottom: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.main::-webkit-scrollbar {
    display: none;
}

.feed {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 60px;
}

@media (min-width: 768px) {
    .feed {
        width: 60%;
        max-width: 600px;
    }
}

/* ===== Mad Cards Section ===== */
.mads-section {
    padding: 16px 0;
}

.mads-carousel {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 8px 5%;
}

.mads-carousel::-webkit-scrollbar {
    display: none;
}

/* ===== Mad Card ===== */
.mad-card {
    flex: 0 0 98%;
    scroll-snap-align: center;
    height: 250px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}



.mad-content {
    height: 90%;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.mad-text {
    flex: 1;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    overflow-y: auto;
    padding-bottom: 60px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.mad-text::-webkit-scrollbar {
    display: none;
}

/* Mad Card Images */
.mad-images {
    position: absolute;
    bottom: 45px;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 2;
    gap: 8px;
    pointer-events: none;
    padding: 30px 0 0 0;
    background: linear-gradient(to top, var(--bg-secondary) 40%, transparent);
}

/* Remove ::before, fade is now on container */
.mad-images::before {
    display: none;
}

.mad-image-wrapper {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}

/* Default hidden state */
.mad-card:not(.in-view) .mad-image-wrapper {
    opacity: 0;
    transform: translateY(50px);
}

.mad-card:not(.in-view) .mad-image-wrapper:nth-child(1) {
    transform: translateY(50px) rotate(-25deg);
}

.mad-card:not(.in-view) .mad-image-wrapper:nth-child(3) {
    transform: translateY(50px) rotate(25deg);
}

/* Visible/animated state */
.mad-card.in-view .mad-image-wrapper {
    opacity: 1;
}

.mad-card.in-view .mad-image-wrapper:nth-child(1) {
    transform: rotate(-5deg);
    transition-delay: 0.1s;
}

.mad-card.in-view .mad-image-wrapper:nth-child(2) {
    transform: translateY(-1px) rotate(0deg);
    transition-delay: 0.15s;
}

.mad-card.in-view .mad-image-wrapper:nth-child(3) {
    transform: rotate(5deg);
    transition-delay: 0.2s;
}

/* Single image */
.mad-card.in-view .mad-image-wrapper.single {
    transform: rotate(0deg);
}

/* Double images */
.mad-card.in-view .mad-image-wrapper.double:nth-child(1) {
    transform: rotate(-5deg);
}

.mad-card.in-view .mad-image-wrapper.double:nth-child(2) {
    transform: rotate(5deg);
}

.mad-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

/* Mad Card Footer */
.mad-footer {
    height: 10%;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: relative;
    z-index: 3;
}

.mad-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mad-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.mad-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.mad-username {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.mad-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.mad-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mad-action {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.mad-action i {
    font-size: 1.25rem;
}

.mad-action span {
    font-size: 0.8rem;
}

.mad-action.like.active {
    color: var(--like-color);
}

.mad-action.like.active i {
    animation: heartPop 0.3s ease;
}

@keyframes heartPop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

/* ===== Posts Section ===== */
.posts-section {
    display: flex;
    flex-direction: column;
    background: var(--border-color);
}

.post {
    background: var(--bg-primary);
    padding: 16px;
    border-bottom: 0.5px solid var(--border-color);
}

.post:last-child {
    border-bottom: none;
}

.post-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.post-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.post-user-info {
    display: flex;
    flex-direction: column;
}

.post-username {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.post-time {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.post-more {
    color: var(--text-tertiary);
    padding: 8px;
    border-radius: 50%;
    transition: background-color var(--transition-fast);
}

.post-more:hover {
    background-color: var(--bg-tertiary);
}

.post-more i {
    font-size: 1.5rem;
}

.post-content {
    margin-bottom: 12px;
    position: relative;
    cursor: pointer;
}

/* Scrollable inner content */
.post-content-inner {
    max-height: 350px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.post-content-inner::-webkit-scrollbar {
    display: none;
}

/* Only show fade for posts with overflow */
.post-content.has-overflow .post-content-inner {
    padding-bottom: 70px;
}

.post-content.has-overflow::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, transparent, var(--bg-primary));
    pointer-events: none;
    z-index: 10;
}

.post-text {
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Post Images */
.post-images {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    position: relative;
    height: 190px;
}

.post-image-wrapper {
    position: absolute;
    transition: transform var(--transition-normal);
}

.post-image-wrapper img {
    height: 170px;
    width: auto;
    max-width: 280px;
    object-fit: cover;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* Image rotation and positioning for 3 images */
.post-images.images-3 .post-image-wrapper:nth-child(1) {
    transform: translateX(-60px) rotate(-5deg);
    z-index: 1;
}

.post-images.images-3 .post-image-wrapper:nth-child(2) {
    transform: rotate(0deg);
    z-index: 3;
}

.post-images.images-3 .post-image-wrapper:nth-child(3) {
    transform: translateX(60px) rotate(5deg);
    z-index: 1;
}

/* Image rotation and positioning for 2 images */
.post-images.images-2 .post-image-wrapper:nth-child(1) {
    transform: translateX(-40px) rotate(-5deg);
    z-index: 1;
}

.post-images.images-2 .post-image-wrapper:nth-child(2) {
    transform: translateX(40px) rotate(5deg);
    z-index: 2;
}

/* Single image - centered */
.post-images.images-1 .post-image-wrapper {
    transform: rotate(0deg);
    z-index: 1;
}

.post-actions {
    display: flex;
    align-items: center;
    gap: 24px;
    padding-top: 12px;
}

.post-action {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.post-action i {
    font-size: 1.4rem;
}

.post-action span {
    font-size: 0.85rem;
}

.post-action.like.active {
    color: var(--like-color);
}

.post-action.save.active {
    color: var(--save-color);
}

.post-action:hover {
    color: var(--text-primary);
}

/* ===== Footer Navigation ===== */
.footer-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 60px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 20px;
    z-index: 100;
    transition: background-color var(--transition-normal);
    width: 100%;
    max-width: 600px;
}

@media (min-width: 768px) {
    .footer-nav {
        width: 60%;
    }
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    color: var(--text-tertiary);
    transition: color var(--transition-fast), transform var(--transition-fast);
}

.nav-item i {
    font-size: 1.6rem;
}

.nav-item:hover {
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--text-primary);
}

.nav-item:active {
    transform: scale(0.95);
}

/* ===== Pages ===== */
.page {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    bottom: 60px;
    width: 100%;
    max-width: 600px;
    background: var(--bg-primary);
    border-radius: 0 0 16px 16px;
    z-index: 50;
    display: none;
    flex-direction: column;
    transition: background-color var(--transition-normal);
    overflow: hidden;
}

@media (min-width: 768px) {
    .page {
        width: 60%;
    }
}

.page.active {
    display: flex;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0 0 16px 16px;
    background: var(--bg-primary);
}

.page-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.settings-btn {
    padding: 8px;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: background-color var(--transition-fast);
}

.settings-btn:hover {
    background-color: var(--bg-tertiary);
}

.settings-btn i {
    font-size: 1.5rem;
}

/* Profile Page */
.profile-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 20px;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.profile-content::-webkit-scrollbar {
    display: none;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 16px;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.profile-handle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.profile-stats {
    display: flex;
    gap: 40px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Search Page */
.search-content {
    padding: 16px 20px;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.search-content::-webkit-scrollbar {
    display: none;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 12px 16px;
}

.search-input-wrapper i {
    font-size: 1.25rem;
    color: var(--text-tertiary);
}

.search-input {
    flex: 1;
    background: none;
    font-size: 1rem;
    color: var(--text-primary);
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

/* Chat Page */
.chat-content {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chat-content::-webkit-scrollbar {
    display: none;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
    cursor: pointer;
}

.chat-item:hover {
    background-color: var(--bg-secondary);
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.chat-name {
    font-size: 0.95rem;
    font-weight: 600;
}

.chat-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

/* ===== Settings Page ===== */
.settings-page {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: 100%;
    max-width: 600px;
    background: var(--bg-primary);
    border-radius: 0 0 16px 16px;
    z-index: 200;
    display: none;
    flex-direction: column;
    transition: background-color var(--transition-normal);
}

@media (min-width: 768px) {
    .settings-page {
        width: 60%;
    }
}

.settings-page.active {
    display: flex;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
    padding: 0 20px;
    position: relative;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0 0 16px 16px;
    background: var(--bg-primary);
}

.settings-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.settings-back {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.settings-back:hover {
    opacity: 0.7;
}

.settings-back i {
    font-size: 1.5rem;
}

.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px 24px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.settings-content::-webkit-scrollbar {
    display: none;
}

.settings-group {
    margin-bottom: 24px;
}

.settings-group-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 8px 4px 12px;
}

.settings-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 0.5px solid var(--border-color);
    transition: background-color var(--transition-fast);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item.clickable {
    cursor: pointer;
}

.settings-item.clickable:active {
    background-color: var(--bg-tertiary);
}

.settings-item-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
}

.settings-item-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-item-icon i {
    font-size: 1.3rem;
    color: var(--text-secondary);
}

.settings-item-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-item-label {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.settings-item-value {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.settings-item-right {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-tertiary);
}

.settings-item-right span {
    font-size: 0.9rem;
}

.settings-item-right i {
    font-size: 1rem;
}

.settings-item.logout .settings-item-label {
    color: var(--danger-color);
}

.settings-item.logout .settings-item-icon i {
    color: var(--danger-color);
}

/* Toggle Switch - Green Style */
.toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 30px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--bg-tertiary);
    border-radius: 30px;
    transition: background-color var(--transition-normal);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 26px;
    width: 26px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: transform var(--transition-normal);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle input:checked+.toggle-slider {
    background-color: #34c759;
}

.toggle input:checked+.toggle-slider::before {
    transform: translateX(20px);
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mad-card {
    animation: fadeIn 0.4s ease backwards;
}

.mad-card:nth-child(1) {
    animation-delay: 0.1s;
}

.mad-card:nth-child(2) {
    animation-delay: 0.2s;
}

.mad-card:nth-child(3) {
    animation-delay: 0.3s;
}

.mad-card:nth-child(4) {
    animation-delay: 0.4s;
}

.post {
    animation: fadeIn 0.4s ease backwards;
}

/* ===== Scrollbar Styling ===== */
/* All scrollbars hidden globally */
::-webkit-scrollbar {
    display: none;
}

* {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* ===== Safe Area (Notch/Home Indicator) ===== */
@supports (padding: max(0px)) {
    .footer-nav {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
        height: calc(64px + max(0px, env(safe-area-inset-bottom)));
    }

    .page {
        bottom: calc(64px + max(0px, env(safe-area-inset-bottom)));
    }
}

/* ===== Post Preview Overlay ===== */
.post-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 300;
    display: none;
    flex-direction: column;
}

.post-preview-overlay.active {
    display: flex;
}

.post-preview-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

@media (min-width: 768px) {
    .post-preview-container {
        width: 60%;
    }
}

.post-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0 0 16px 16px;
    background: var(--bg-primary);
    flex-shrink: 0;
}

.post-preview-back {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.post-preview-back:hover {
    opacity: 0.7;
}

.post-preview-back i {
    font-size: 1.5rem;
}

.post-preview-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.post-preview-action {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.post-preview-action i {
    font-size: 1.4rem;
}

.post-preview-action span {
    font-size: 0.85rem;
}

.post-preview-action.like.active {
    color: var(--like-color);
}

.post-preview-action.save.active {
    color: var(--save-color);
}

.post-preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.post-preview-content::-webkit-scrollbar {
    display: none;
}

.post-preview-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.post-preview-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.post-preview-user-info {
    display: flex;
    flex-direction: column;
}

.post-preview-username {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.post-preview-time {
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.post-preview-text {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.post-preview-images {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 190px;
    margin-top: 16px;
}

.post-preview-image-wrapper {
    position: absolute;
    transition: transform var(--transition-normal);
}

.post-preview-image-wrapper img {
    height: 170px;
    width: auto;
    max-width: 280px;
    object-fit: cover;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* Preview image rotation and positioning for 3 images */
.post-preview-images.images-3 .post-preview-image-wrapper:nth-child(1) {
    transform: translateX(-60px) rotate(-5deg);
    z-index: 1;
}

.post-preview-images.images-3 .post-preview-image-wrapper:nth-child(2) {
    transform: rotate(0deg);
    z-index: 3;
}

.post-preview-images.images-3 .post-preview-image-wrapper:nth-child(3) {
    transform: translateX(60px) rotate(5deg);
    z-index: 1;
}

/* Preview image rotation and positioning for 2 images */
.post-preview-images.images-2 .post-preview-image-wrapper:nth-child(1) {
    transform: translateX(-40px) rotate(-5deg);
    z-index: 1;
}

.post-preview-images.images-2 .post-preview-image-wrapper:nth-child(2) {
    transform: translateX(40px) rotate(5deg);
    z-index: 2;
}

/* Single preview image - centered */
.post-preview-images.images-1 .post-preview-image-wrapper {
    transform: rotate(0deg);
    z-index: 1;
}

/* ===== Post Options Bottom Sheet ===== */
.post-options-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.post-options-overlay.active {
    opacity: 1;
    visibility: visible;
}

.post-options-sheet {
    width: 100%;
    max-height: 80vh;
    background: #121212;
    border-radius: 20px 20px 0 0;
    padding: 12px 16px 32px;
    transform: translateY(100%);
    transition: transform var(--transition-normal);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.post-options-sheet::-webkit-scrollbar {
    display: none;
}

@media (min-width: 768px) {
    .post-options-sheet {
        width: 60%;
    }
}

.post-options-overlay.active .post-options-sheet {
    transform: translateY(0);
}

.post-options-handle {
    width: 36px;
    height: 4px;
    background: var(--text-tertiary);
    border-radius: 2px;
    margin: 0 auto 20px;
}

.post-options-group {
    background: #1a1a1a;
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    overflow: hidden;
}

.post-options-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 20px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: left;
}

.post-options-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.post-options-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.post-options-item i {
    font-size: 1.3rem;
    color: var(--text-secondary);
}

.post-options-item.danger {
    color: #ff3b30;
}

.post-options-item.danger i {
    color: #ff3b30;
}

/* ===== Comments Modal ===== */
.comments-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.comments-overlay.active {
    opacity: 1;
    visibility: visible;
}

.comments-sheet {
    width: 100%;
    height: 50vh;
    min-height: 300px;
    max-height: 90vh;
    background: var(--bg-primary);
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform var(--transition-normal), height 0.2s ease;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

@media (min-width: 768px) {
    .comments-sheet {
        width: 60%;
    }
}

.comments-overlay.active .comments-sheet {
    transform: translateY(0);
}

.comments-sheet.full-height {
    height: 90vh;
}

.comments-handle {
    width: 36px;
    height: 4px;
    background: var(--text-tertiary);
    border-radius: 2px;
    margin: 10px auto;
    cursor: grab;
    flex-shrink: 0;
}

.comments-handle:active {
    cursor: grabbing;
}

.comments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    cursor: grab;
    user-select: none;
}

.comments-header:active {
    cursor: grabbing;
}

.comments-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.comments-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

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

.comments-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.comments-list::-webkit-scrollbar {
    display: none;
}

.comment-item {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.comment-content {
    flex: 1;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.comment-username {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.comment-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.comment-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
    /* Standard for modern browsers */
    height: auto;
}

.comment-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
}

.comment-action {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    background: none;
    border: none;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.comment-action:hover {
    color: var(--text-primary);
}

.comment-action i {
    font-size: 1rem;
}

.comments-empty {
    text-align: center;
    color: var(--text-tertiary);
    padding: 40px 20px;
}

.comments-input-area {
    display: flex;
    align-items: center;
    height: 50px;
    padding: 0 16px;
    border-top: 1px solid var(--border-color);
    border-radius: 16px 16px 0 0;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.comments-input {
    width: 95%;
    height: 50px;
    background: transparent;
    border: none;
    padding: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-family: inherit;
}

.comments-input::placeholder {
    color: var(--text-tertiary);
}

.comments-input:focus {
    outline: none;
}

.comments-send {
    width: 5%;
    min-width: 32px;
    height: 50px;
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
}

.comments-send:hover {
    transform: scale(1.1);
}