:root {
    /* Premium Dark Theme base (Navy/Black vibe) */
    --bg-color: #05080f;
    --card-bg: rgba(18, 24, 38, 0.65);
    --card-hover-bg: rgba(22, 30, 48, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;

    /* Teal/Mint accents combining professional & trendy feeling */
    --accent-color: #00d1b2;
    --accent-glow: rgba(20, 184, 166, 0.15);
    --hover-bg: rgba(20, 184, 166, 0.08);

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 84px;
    --panel-width: 310px;
    --feed-max-width: 820px; /* Tighter width for better reading experience */
    --header-height-mobile: 64px;

    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 28px;

    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.25);
    --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.4);
    
    /* Typography Spacing - Refined */
    --lh-base: 1.65;
    --ls-base: 0.005em;
    --ls-tight: -0.02em;
}

[data-theme="light"] {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --card-hover-bg: #fafafa;
    --border-color: rgba(0, 0, 0, 0.05);
    --text-color: #0f172a;
    --text-muted: #64748b;
    --accent-color: #00a896;
    --accent-glow: rgba(13, 148, 136, 0.12);
    --hover-bg: rgba(13, 148, 136, 0.06);

    --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 16px 50px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: var(--lh-base);
    letter-spacing: var(--ls-base);
    overflow-y: scroll;
    transition: background-color 0.4s ease, color 0.4s ease;
    word-break: keep-all;

    background-image: radial-gradient(circle at 10% 20%, rgba(20, 184, 166, 0.04), transparent 30%),
        radial-gradient(circle at 90% 80%, rgba(20, 184, 166, 0.04), transparent 30%);
}

a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-color);
}

/* Animations Core */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

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

.animate-fade-up {
    animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    /* Ensures it stays invisible before animation triggering */
}

/* Delay modifiers for sequential entry */
.delay-100 {
    animation-delay: 100ms;
}

.delay-200 {
    animation-delay: 200ms;
}

.delay-300 {
    animation-delay: 300ms;
}

.delay-400 {
    animation-delay: 400ms;
}

/* 3-Column Grid Layout */
.layout-container {
    display: grid;
    grid-template-columns: var(--sidebar-collapsed-width) minmax(680px, 1fr) var(--panel-width);
    width: 100%;
    max-width: 1600px;
    min-height: 100vh;
    padding: 30px 40px;
    gap: 50px;
    margin: 0 auto;
    align-items: start;
}

/* --- Sidebar --- */
.sidebar {
    position: sticky;
    top: 30px;
    height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    padding: 10px;
    width: var(--sidebar-collapsed-width);
    overflow: hidden;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 50;
    margin-left: -80px;
    /* Fixed: Prevents the sidebar from being hidden */
    border-radius: var(--radius-lg);
}

.sidebar:hover {
    width: var(--sidebar-width);
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
}

.logo {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 50px;
    padding: 15px 15px;
    display: flex;
    align-items: center;
    min-height: 55px;
    color: var(--text-color);
    white-space: nowrap;
    letter-spacing: -0.03em;
}

.logo-text {
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    background: linear-gradient(90deg, #fff, var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;

    [data-theme="light"] & {
        background: linear-gradient(90deg, #000, var(--accent-color));
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
    }
}

.sidebar:hover .logo-text {
    opacity: 1;
    transform: translateX(0);
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 15px;
    border-radius: 16px;
    font-weight: 500;
    font-size: 1.1rem;
    white-space: nowrap;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.nav-links li a:hover {
    background: var(--hover-bg);
    color: var(--accent-color);
    transform: translateX(4px);
}

.nav-links li a i {
    font-size: 1.4rem;
    width: 24px;
    min-width: 24px;
    text-align: center;
}

.nav-links li a span {
    opacity: 0;
    transform: translateX(-5px);
    transition: all 0.3s ease;
}

.sidebar:hover .nav-links li a span {
    opacity: 1;
    transform: translateX(0);
}

/* --- Main Feed --- */
.main-feed {
    width: 100%;
    max-width: var(--feed-max-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 48px; /* Balanced spacing between sections */
    justify-self: center;
    padding-bottom: 80px;
}

/* Card Style (Premium App Vibe) */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px 44px;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.card:hover, .card:active {
    border-color: rgba(0, 209, 178, 0.25);
    background: var(--card-hover-bg);
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
}

/* Feed specific card (like insta post) */
.feed-card {
    padding: 0;
    border-radius: var(--radius-md);
}

.feed-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.feed-content {
    padding: 24px;
}

.feed-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: -0.01em;
}

/* --- Right Profile Panel --- */
.profile-panel {
    position: sticky;
    top: 30px;
    width: var(--panel-width);
    height: max-content;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-soft);
}

.profile-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-img-wrapper {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    overflow: hidden;
    padding: 4px;
    border: 2px solid var(--accent-color);
    margin: 0 auto 10px;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.profile-img-wrapper:hover {
    transform: scale(1.05);
}

.profile-img-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    overflow: hidden;
}

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

.profile-info {
    text-align: center;
}

.profile-name {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

.profile-major {
    color: var(--accent-color);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 12px;
}

.profile-intro {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-color);
    text-align: center;
    margin-top: 5px;
}

.profile-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.profile-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text-color);
    transition: all 0.3s ease;
}

.profile-link:hover {
    color: #fff;
    background: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--accent-glow);
}

/* Typography & Utilities */
.badge {
    background: var(--hover-bg);
    color: var(--accent-color);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.8rem;
    display: inline-block;
    font-weight: 600;
    border: 1px solid rgba(20, 184, 166, 0.2);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--bg-color);
    color: var(--text-color);
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.btn-primary {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.btn:hover {
    background: var(--card-hover-bg);
    transform: translateY(-2px);
}

.btn-primary:hover {
    background: #0f9688;
    box-shadow: 0 6px 20px var(--accent-glow);
}

/* Home Hero Section */
.hero-section {
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.hero-title {
    font-size: 3.2rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.04em;
    background: linear-gradient(135deg, #fff 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;

    [data-theme="light"] & {
        background: linear-gradient(135deg, #111 0%, var(--text-muted) 100%);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
    }
}

.hero-title .highlight {
    background: linear-gradient(135deg, var(--accent-color) 0%, #38bdf8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 400;
    max-width: 600px;
    line-height: 1.7;
}

/* Mobile/Desktop Visibility Utilities */
.mobile-only { display: none !important; }
.desktop-only { display: flex !important; }

@media (max-width: 768px) {
    .mobile-only { display: block !important; }
    .mobile-only.flex { display: flex !important; }
    .desktop-only { display: none !important; }
}

/* Compact Select UI - App Style */
.compact-select {
    appearance: none;
    background: var(--card-bg);
    color: var(--text-color);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0 40px 0 16px;
    height: 44px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%2394a3b8%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
}

.compact-select:hover, .compact-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 209, 178, 0.1);
}

.compact-select option {
    background: #1a1f2b; /* Force dark background for options */
    color: #fff;
}

/* Markdown Rendering Customization - Refined for Readability */
.markdown-content {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    line-height: var(--lh-base);
}

.markdown-content h1, 
.markdown-content h2, 
.markdown-content h3 {
    color: var(--text-color);
    line-height: 1.3;
    letter-spacing: var(--ls-tight);
}

.markdown-content h1 { font-size: 1.25rem; font-weight: 800; margin: 2.5rem 0 1.2rem; }
.markdown-content h2 { font-size: 1.15rem; font-weight: 700; margin: 2rem 0 1rem; }
.markdown-content h3 { font-size: 1.05rem; font-weight: 700; margin: 1.5rem 0 0.8rem; }

@media (max-width: 768px) {
    .markdown-content h1 { font-size: 1.05rem; margin-top: 2rem; }
    .markdown-content h2 { font-size: 0.95rem; margin-top: 1.5rem; }
    .markdown-content h3 { font-size: 0.9rem; margin-top: 1.2rem; }
    .markdown-content p { font-size: 0.9rem; margin-bottom: 1.5rem; line-height: 1.7; }
    .markdown-content li { font-size: 0.9rem; margin-bottom: 0.6rem; }
}

.markdown-content p {
    font-size: 1rem;
    color: var(--text-color);
    margin-bottom: 1.8rem;
    word-break: keep-all;
}

.markdown-content ul, 
.markdown-content ol {
    margin-bottom: 1.8rem;
    padding-left: 1.5rem;
}

.markdown-content li {
    margin-bottom: 0.7rem;
    font-size: 1rem;
}

.markdown-content blockquote {
    border-left: 3px solid var(--accent-color);
    background: var(--hover-bg);
    padding: 18px 24px;
    margin: 2rem 0;
    border-radius: 0 12px 12px 0;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.markdown-content pre {
    margin: 2rem 0;
    padding: 20px;
    border-radius: 16px;
    background: #0d1117;
    border: 1px solid rgba(255,255,255,0.05);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.markdown-content code {
    font-family: 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 0.85em;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    background: rgba(255,255,255,0.08);
    color: var(--accent-color);
}

.markdown-content pre code {
    padding: 0;
    background: transparent;
    color: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
}

.markdown-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 3.5rem auto;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.markdown-content hr {
    margin: 4rem 0;
    border: 0;
    border-top: 1px solid var(--border-color);
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2.5rem 0;
    font-size: 0.9rem;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.markdown-content th, 
.markdown-content td {
    padding: 16px 20px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.markdown-content th {
    background: var(--hover-bg);
    font-weight: 700;
}

[data-theme="light"] .markdown-content pre {
    background: #f6f8fa;
    border-color: #d0d7de;
}

[data-theme="light"] .markdown-content blockquote {
    background: #f8fafc;
}

/* Spec Table Styles */
.spec-header {
    display: grid;
    grid-template-columns: 28px 2fr 1fr 120px 110px;
    gap: 0;
    padding: 8px 16px 8px 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 4px;
}

.spec-row {
    display: grid;
    grid-template-columns: 28px 2fr 1fr 120px 110px;
    align-items: center;
    gap: 0;
    padding: 13px 16px 13px 0;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s, opacity 0.2s;
    border-radius: 8px;
    cursor: pointer;
}

.spec-row:hover {
    background: var(--hover-bg);
}

@media (max-width: 920px) {
    .spec-header {
        display: none; /* Hide header on small screens */
    }
    .spec-row {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 20px;
        position: relative;
    }
    .spec-row .drag-handle {
        position: absolute;
        right: 15px;
        top: 20px;
    }
}

/* Responsive Overrides */
.header-mobile {
    display: none;
}

.bottom-nav {
    display: none;
}

@media (max-width: 1280px) {
    .layout-container {
        grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr) 260px;
        padding: 24px 32px;
        gap: 30px;
    }
}

@media (max-width: 1024px) {
    .layout-container {
        grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
        padding: 20px 24px;
        gap: 20px;
    }

    .profile-panel {
        display: none;
    }

    .hero-title {
        font-size: 2.6rem;
    }
}

@media (max-width: 768px) {
    .layout-container {
        grid-template-columns: minmax(0, 1fr);
        padding: 0 20px;
        margin-top: calc(var(--header-height-mobile) + 24px);
        margin-bottom: 100px;
        gap: 30px;
    }

    .sidebar {
        display: none;
    }

    /* Mobile Typography Refinement */
    .hero-title {
        font-size: 1.7rem; /* ~27px */
        line-height: 1.25;
        margin-bottom: 10px;
        letter-spacing: var(--ls-tight);
    }

    .hero-subtitle {
        font-size: 0.95rem;
        margin-bottom: 6px;
        color: var(--text-muted);
    }

    .feed-title {
        font-size: 1.15rem; /* ~18.5px */
        margin-bottom: 8px;
    }

    h1, h2, h3 {
        letter-spacing: var(--ls-tight);
    }

    .card {
        padding: 28px 24px;
        border-radius: var(--radius-md);
        gap: 16px;
    }

    .main-feed {
        gap: 32px;
    }

    /* Top Mobile Header (Premium Blur) */
    .header-mobile {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: var(--header-height-mobile);
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        background: rgba(5, 8, 15, 0.75);
        border-bottom: 1px solid var(--border-color);
        z-index: 1000;
        padding: 0 20px;
        backdrop-filter: blur(28px);
        -webkit-backdrop-filter: blur(28px);

        [data-theme="light"] & {
            background: rgba(255, 255, 255, 0.75);
        }
    }

    .header-mobile h1 {
        font-size: 1.15rem;
        font-weight: 800;
        letter-spacing: -0.04em;
        background: linear-gradient(90deg, #fff, var(--accent-color));
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;

        [data-theme="light"] & {
            background: linear-gradient(90deg, #0f172a, var(--accent-color));
        }
    }

    /* Bottom Mobile Nav (App Vibe) */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: rgba(18, 24, 38, 0.9);
        border-top: 1px solid var(--border-color);
        z-index: 1000;
        height: 70px;
        justify-content: space-around;
        align-items: center;
        backdrop-filter: blur(28px);
        -webkit-backdrop-filter: blur(28px);
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
        transition: transform 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.1);
        will-change: transform;

        [data-theme="light"] & {
            background: rgba(255, 255, 255, 0.9);
        }
    }

    .bottom-nav.nav-hidden {
        transform: translateY(105%);
    }

    .bottom-nav a {
        color: var(--text-muted);
        font-size: 1.5rem;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
        transition: all 0.3s ease;
        position: relative;
    }

    .bottom-nav a.active {
        color: var(--accent-color);
        transform: translateY(-2px);
    }
    
    .bottom-nav a.active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 32px;
        height: 4px;
        background: var(--accent-color);
        border-radius: 0 0 4px 4px;
        box-shadow: 0 0 12px var(--accent-glow);
    }

    .btn {
        padding: 14px 24px;
        width: 100%;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .layout-container {
        padding: 0 16px;
    }

    .hero-title {
        font-size: 2.2rem;
    }

    .card {
        padding: 28px 24px;
    }
}