:root {
    --bg-dark: #f8fbf8;
    --bg-color: #f8fbf8;
    --sidebar-bg: rgba(255, 255, 255, 0.58);
    --glass-bg: rgba(255, 255, 255, 0.68);
    --glass-border: rgba(255, 255, 255, 0.72);
    --glass-edge: rgba(183, 200, 206, 0.58);
    --accent-primary: linear-gradient(135deg, #007e54 0%, #1fa7e1 100%);
    --accent-secondary: linear-gradient(135deg, #1fa7e1 0%, #b6d832 100%);
    --accent-danger: linear-gradient(135deg, #b91c1c 0%, #ef4444 100%);
    --accent-blue: #1fa7e1;
    --accent-green: #007e54;
    --accent-lime: #b6d832;
    --accent-soft: #eefaff;
    --text-primary: #10202c;
    --text-main: #10202c;
    --text-secondary: #344955;
    --text-muted: #647583;
    --card-shadow: 0 26px 70px rgba(20, 65, 88, 0.14), 0 8px 24px rgba(0, 126, 84, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.88);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-soft: cubic-bezier(0.16, 1, 0.3, 1);
    --motion-fast: 150ms;
    --motion-medium: 260ms;
    --motion-slow: 360ms;
    --transition-smooth: all var(--motion-medium) var(--ease-out);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

html {
    scroll-behavior: smooth;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        linear-gradient(120deg, rgba(255, 229, 220, 0.78), rgba(238, 250, 255, 0.9) 46%, rgba(246, 255, 219, 0.82));
    background-attachment: scroll;
}

body.app-route-leaving .main-workspace {
    opacity: 0;
    transform: translateY(8px) scale(0.995);
    filter: blur(1px);
}

/* Premium Light Glass Core */
.glass {
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.58)),
        var(--glass-bg);
    backdrop-filter: blur(24px) saturate(145%);
    -webkit-backdrop-filter: blur(24px) saturate(145%);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    transition:
        transform var(--motion-medium) var(--ease-out),
        box-shadow var(--motion-medium) var(--ease-out),
        border-color var(--motion-medium) var(--ease-out),
        background var(--motion-medium) var(--ease-out);
}

.glass-hover:hover {
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(238, 250, 255, 0.62));
    border-color: rgba(31, 167, 225, 0.30);
    transform: translateY(-2px);
}

button,
a,
input,
select,
textarea,
.nav-link,
.action-btn,
.btn-primary,
.btn-secondary,
.btn-cancel,
.btn-publish {
    transition:
        transform var(--motion-fast) var(--ease-out),
        background-color var(--motion-fast) ease,
        border-color var(--motion-fast) ease,
        color var(--motion-fast) ease,
        box-shadow var(--motion-fast) ease,
        opacity var(--motion-fast) ease;
}

button:active,
a.nav-link:active,
a[class*="btn"]:active,
a[role="button"]:active,
.mobile-bottom-nav a:active,
.action-btn:active,
.btn-primary:active,
.btn-secondary:active,
.btn-cancel:active,
.btn-publish:active {
    transform: scale(0.985);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    transform: none !important;
}

img,
video {
    backface-visibility: hidden;
}

/* Layout - 3 Pane Dashboard */
.app-container {
    display: grid;
    grid-template-columns: 280px 1fr 340px;
    gap: 24px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 90px 24px 24px;
    min-height: 100vh;
}

/* Top Navigation Bar */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    background: rgba(255, 255, 255, 0.74);
    backdrop-filter: blur(24px) saturate(150%);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    border-bottom: 1px solid var(--glass-border);
    box-shadow: 0 12px 36px rgba(20, 65, 88, 0.10);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-text {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--accent-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-wrapper {
    position: relative;
    width: 450px;
}

.search-wrapper i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.global-search {
    width: 100%;
    padding: 12px 16px 12px 48px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid rgba(183, 200, 206, 0.70);
    color: var(--text-primary);
    backdrop-filter: blur(16px) saturate(130%);
    -webkit-backdrop-filter: blur(16px) saturate(130%);
    font-size: 14px;
    transition: var(--transition-smooth);
}

.global-search:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.92);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(31, 167, 225, 0.14);
}

/* Left Navigation Panel */
.left-nav {
    position: sticky;
    top: 94px;
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    text-decoration: none;
    color: #455b66;
    border-radius: 8px;
    font-weight: 700;
    transition: var(--transition-smooth);
}

.nav-link i {
    font-size: 20px;
    width: 24px;
    text-align: center;
    color: #6a7d88;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(var(--nav-color-rgb, 31, 167, 225), 0.10);
}

.nav-link:hover i {
    color: rgb(var(--nav-color-rgb, 0, 126, 84));
}

/* --- DYNAMIC ACTIVE LINK --- */
.nav-link.active {
    background: rgba(var(--nav-color-rgb, 0, 126, 84), 0.10);
    border-left: 3px solid rgb(var(--nav-color-rgb, 0, 126, 84));
    color: var(--text-primary);
    box-shadow: inset 30px 0 30px -30px rgba(var(--nav-color-rgb, 0, 126, 84), 0.26);
    border-radius: 0 8px 8px 0;
}

.nav-link.active i {
    color: rgb(var(--nav-color-rgb, 0, 126, 84));
}

.nav-badge {
    margin-left: auto;
    background: #ef4444;
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
}

/* Central Dynamic Workspace */
.main-workspace {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: workspaceEnter var(--motion-slow) var(--ease-soft);
    transition:
        opacity var(--motion-medium) var(--ease-out),
        transform var(--motion-medium) var(--ease-out),
        filter var(--motion-medium) var(--ease-out);
    will-change: opacity, transform;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes workspaceEnter {
    from { opacity: 0; transform: translateY(12px) scale(0.998); filter: blur(1px); }
    to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.main-workspace.app-transition-out {
    opacity: 0;
    transform: translateY(8px) scale(0.997);
    filter: blur(1px);
}

.main-workspace.app-transition-in {
    animation: workspaceEnter var(--motion-medium) var(--ease-soft);
}

/* Horizontal Story Bar */
.stories-container {
    display: flex;
    gap: 18px;
    padding: 10px 5px;
    overflow-x: auto;
    scrollbar-width: none;
}

@media (hover: hover) and (pointer: fine) {
    .glass-hover:hover,
    .nav-link:hover,
    button:hover,
    .action-btn:hover {
        will-change: transform;
    }
}

@media (max-width: 768px) {
    body {
        background-attachment: scroll;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
    }

    body.app-route-leaving .main-workspace,
    .main-workspace.app-transition-out {
        opacity: 1;
        transform: none;
        filter: none;
    }
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    min-width: 75px;
}

.story-ring {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    padding: 3px;
    background: var(--accent-primary);
    position: relative;
    transition: var(--transition-smooth);
}

.story-ring.seen {
    background: var(--glass-border);
}

.story-ring img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid #ffffff;
    object-fit: cover;
}

.story-item:hover .story-ring {
    transform: scale(1.05);
}

.story-name {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Post Creation Area */
.create-post-box {
    padding: 24px;
}

.create-post-header {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    object-fit: cover;
}

.post-textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    resize: none;
    padding-top: 8px;
}

.post-textarea:focus {
    outline: none;
}

.create-post-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--glass-border);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.action-btn:hover {
    background: rgba(31, 167, 225, 0.08);
    color: var(--text-primary);
}

/* Post Card */
.post-card {
    padding: 24px;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.post-author-info h4 {
    font-size: 15px;
    font-weight: 600;
}

.post-author-info p {
    font-size: 13px;
    color: var(--text-muted);
}

.post-body {
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.post-stats {
    display: flex;
    gap: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--glass-border);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.stat-item:hover {
    color: var(--accent-blue);
}

/* Right Intelligent Panel */
.right-panel {
    position: sticky;
    top: 94px;
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.panel-section {
    padding: 24px;
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.activity-item {
    display: flex;
    gap: 14px;
    margin-bottom: 18px;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(31, 167, 225, 0.10);
    color: var(--accent-blue);
}

/* Messaging System */
.chat-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - 140px);
    overflow: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Tab Styles */
.active-tab {
    padding: 10px 20px;
    text-decoration: none;
    color: white;
    font-size: 14px;
    font-weight: 600;
    background: var(--accent-primary);
    border: none;
}

.inactive-tab {
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
}

.liked {
    color: #ef4444 !important;
}

/* Flash Messages */
.flash-message {
    padding: 16px 24px;
    margin-bottom: 8px;
}

.flash-danger {
    border-left: 4px solid #ef4444;
}

.flash-info {
    border-left: 4px solid var(--accent-blue);
}

.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #ffffff;
}

.status-online {
    background: #22c55e;
}

.status-offline {
    background: #64748b;
}
.btn-primary {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 14px 24px rgba(0, 126, 84, 0.18);
    transition: var(--transition-smooth);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 30px rgba(0, 126, 84, 0.20);
}

/* Mobile Responsiveness */
@media (max-width: 1200px) {
    .app-container {
        grid-template-columns: 80px 1fr 300px;
    }
    .nav-text { display: none; }
}

@media (max-width: 992px) {
    .app-container {
        grid-template-columns: 80px 1fr;
    }
    .right-panel { display: none; }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
        padding-top: 80px;
    }
    .left-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 70px;
        flex-direction: row;
        justify-content: space-around;
        background: rgba(255, 255, 255, 0.78);
        backdrop-filter: blur(24px) saturate(145%);
        -webkit-backdrop-filter: blur(24px) saturate(145%);
        backdrop-filter: blur(20px);
        padding: 0 10px;
        z-index: 1000;
        border-top: 1px solid var(--glass-border);
    }
    .nav-link { flex-direction: column; gap: 4px; padding: 10px; font-size: 10px; }
}

/* Shared threaded comments */
body .feed-post-card .comment-compose-row,
body .club-feed-card .comment-compose-row {
    margin: 0 22px 22px !important;
}

body .confession-comment-panel .comment-compose-row {
    margin: 14px 0 0 !important;
}

body .comment-compose-row {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    min-height: 48px !important;
    padding: 0 12px 0 18px !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 10px !important;
    background: rgba(255, 255, 255, 0.82) !important;
}

body .feed-comment-input {
    flex: 1 !important;
    min-width: 0 !important;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    color: var(--text-primary) !important;
    font-size: 14px !important;
}

body .feed-comment-input::placeholder,
body .comment-reply-input::placeholder {
    color: var(--text-muted) !important;
}

body .feed-comment-submit {
    width: 34px !important;
    height: 34px !important;
    border: none !important;
    background: transparent !important;
    color: var(--accent-green) !important;
    cursor: pointer !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 18px !important;
}

body .feed-comment-submit:hover {
    background: rgba(0, 126, 84, 0.10) !important;
}

body .feed-post-card .comment-thread-panel,
body .club-feed-card .comment-thread-panel {
    margin: 0 22px 18px !important;
}

body .confession-comment-panel {
    margin: 16px 0 0 !important;
}

body .comment-thread-panel {
    padding: 16px !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.74) !important;
}

body .comment-thread-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
}

body .comment-thread-title {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    color: var(--text-primary) !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    letter-spacing: 0 !important;
}

body .comment-count-pill {
    min-width: 24px !important;
    height: 22px !important;
    padding: 0 8px !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-blue)) !important;
    color: #ffffff !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    box-shadow: 0 8px 18px rgba(0, 126, 84, 0.16) !important;
}

body .comment-sort-control {
    border: none !important;
    background: transparent !important;
    color: var(--text-muted) !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 13px !important;
    font-weight: 650 !important;
    cursor: default !important;
    padding: 0 !important;
}

body .comment-thread-list {
    max-height: 300px !important;
    overflow-y: auto !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    margin: 0 !important;
    padding: 0 4px 0 0 !important;
}

body .comment-thread-item {
    position: relative !important;
    display: grid !important;
    grid-template-columns: 42px minmax(0, 1fr) !important;
    column-gap: 12px !important;
    padding-bottom: 18px !important;
}

body .comment-thread-item:last-child {
    padding-bottom: 0 !important;
}

body .comment-thread-item:not(:last-child)::before {
    content: "" !important;
    position: absolute !important;
    left: 20px !important;
    top: 44px !important;
    bottom: 2px !important;
    width: 1px !important;
    background: linear-gradient(to bottom, rgba(0, 126, 84, 0.16), rgba(31, 167, 225, 0.03)) !important;
}

body .comment-avatar-wrap {
    position: relative !important;
    z-index: 1 !important;
    width: 42px !important;
    display: flex !important;
    justify-content: center !important;
}

body .comment-avatar {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    border: 2px solid #ffffff !important;
    box-shadow: 0 0 0 1px rgba(16, 32, 44, 0.12) !important;
    background: #ffffff !important;
}

body .comment-anonymous-avatar {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--accent-green) !important;
    font-size: 15px !important;
}

body .comment-main {
    min-width: 0 !important;
    padding-top: 2px !important;
}

body .comment-meta-line {
    display: flex !important;
    align-items: baseline !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin-bottom: 6px !important;
}

body .comment-author-name {
    color: var(--text-primary) !important;
    font-size: 14px !important;
    font-weight: 800 !important;
}

body .comment-time {
    color: var(--text-muted) !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
}

body .comment-content {
    color: var(--text-secondary) !important;
    font-size: 14px !important;
    line-height: 1.55 !important;
    margin: 0 0 9px !important;
    overflow-wrap: anywhere !important;
}

body .comment-action-row {
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    color: var(--text-muted) !important;
    font-size: 12.5px !important;
    font-weight: 650 !important;
}

body .comment-action-row span,
body .comment-action-row button {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
}

body .comment-action-row button {
    border: none !important;
    background: transparent !important;
    color: inherit !important;
    padding: 0 !important;
    cursor: pointer !important;
    font: inherit !important;
}

body .comment-action-row button:hover,
body .comment-like-btn.active,
body .comment-like-btn.active i {
    color: var(--accent-green) !important;
}

body .comment-replies {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    margin-top: 14px !important;
    padding-left: 16px !important;
    border-left: 1px solid var(--glass-border) !important;
}

body .comment-replies:empty {
    display: none !important;
}

body .comment-reply-item {
    grid-template-columns: 36px minmax(0, 1fr) !important;
    padding-bottom: 0 !important;
}

body .comment-reply-item::before {
    display: none !important;
}

body .comment-reply-item .comment-avatar-wrap {
    width: 36px !important;
}

body .comment-reply-item .comment-avatar {
    width: 32px !important;
    height: 32px !important;
    font-size: 13px !important;
}

body .comment-reply-form {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin-top: 12px !important;
    padding: 8px 10px !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.86) !important;
}

body .comment-reply-form[hidden] {
    display: none !important;
}

body .comment-reply-input {
    min-width: 0 !important;
    flex: 1 !important;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    color: var(--text-primary) !important;
    font: inherit !important;
    font-size: 13px !important;
}

body .comment-reply-submit {
    width: 30px !important;
    height: 30px !important;
    border: none !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0, 126, 84, 0.12) !important;
    color: var(--accent-green) !important;
    cursor: pointer !important;
}

body .comment-reply-submit:disabled,
body .feed-comment-submit:disabled {
    opacity: 0.5 !important;
    cursor: wait !important;
}

body .comment-empty-state {
    color: var(--text-muted) !important;
    font-size: 13px !important;
    padding: 4px 0 2px 54px !important;
}

@media (max-width: 768px) {
    body .feed-post-card .comment-compose-row,
    body .feed-post-card .comment-thread-panel,
    body .club-feed-card .comment-compose-row,
    body .club-feed-card .comment-thread-panel {
        margin-left: 16px !important;
        margin-right: 16px !important;
    }

    body .comment-thread-header {
        align-items: flex-start !important;
        flex-direction: column !important;
    }

    body .comment-replies {
        padding-left: 10px !important;
    }
}
