:root {
    /* --- Color Palette (Dark Mode Default) --- */
    --system-bg: #000000;
    --system-blue: #0A84FF;
    --system-white: #FFFFFF;
    --system-gray: #8E8E93;
    --system-gray2: #636366;
    --system-gray3: #48484A;
    --system-gray4: #3A3A3C;
    --system-gray5: #2C2C2E;
    --system-gray6: #1C1C1E;

    /* --- Glassmorphism Tokens --- */
    --glass-bg: rgba(28, 28, 30, 0.6);
    /* Gray 6 with opacity */
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-blur: blur(20px);

    /* --- Tile Specifics --- */
    --tile-bg: rgba(30, 30, 30, 0.75);
    --tile-radius: 18px;
    --tile-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --tile-hover-transform: scale(1.02);
    --tile-transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);

    /* --- Typography --- */
    --font-stack: "SF Pro Display", "SF Pro Text", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    --text-primary: rgba(255, 255, 255, 0.95);
    --text-secondary: rgba(255, 255, 255, 0.60);
    --text-tertiary: rgba(255, 255, 255, 0.40);

    /* --- Layout --- */
    --grid-gap: 24px;
    --page-padding: 40px;
    --max-width: 1200px;
}

/* Light Mode Overrides (Optional - can be toggled via class) */
@media (prefers-color-scheme: light) {
    :root {
        /* Keeping dark mode as default/primary as per request for "Cyber/Space" vibe, 
        but providing light tokens just in case */
        --glass-bg: rgba(255, 255, 255, 0.6);
        --glass-border: rgba(0, 0, 0, 0.1);
        --text-primary: #000000;
        --text-secondary: rgba(60, 60, 67, 0.6);
    }
}

/* --- Global Reset & Base --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-stack);
    background-color: var(--system-bg);
    background-image: url('../images/bg_main.png?v=2');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: scroll;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    /* Safari-specific fixes */
    -webkit-background-size: cover;
    -webkit-transform: translateZ(0);
    /* Force GPU acceleration */
}

a {
    text-decoration: none;
    color: inherit;
}

/* --- Layout Components --- */
.icloud-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--page-padding);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.icloud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 40px;
}

.icloud-branding {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 12px;
}

.icloud-branding svg {
    color: var(--system-white);
}

.icloud-user-menu {
    display: flex;
    gap: 16px;
    align-items: center;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a6abb7, #868a93);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* --- Grid System --- */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--grid-gap);
    width: 100%;
}

/* --- Tile Components --- */
.tile {
    background: var(--tile-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--tile-radius);
    border: 1px solid var(--glass-border);
    box-shadow: var(--tile-shadow);
    overflow: hidden;
    transition: var(--tile-transition);
    display: flex;
    flex-direction: column;
    position: relative;
    height: 320px;
    /* Base height */
}

.tile:hover {
    transform: var(--tile-hover-transform);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
    z-index: 10;
}

/* Tile Variations */
.tile.large {
    grid-column: span 2;
}

@media (max-width: 768px) {
    .tile.large {
        grid-column: span 1;
    }
}

.tile.profile-tile {
    background: linear-gradient(180deg, rgba(40, 40, 45, 0.85) 0%, rgba(20, 20, 20, 0.9) 100%);
    justify-content: center;
    align-items: center;
    text-align: center;
    height: auto !important;
    min-height: 320px;
}

.tile-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
}

.tile-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tile-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.icon-blue {
    background: var(--system-blue);
}

.icon-gray {
    background: var(--system-gray2);
}

.icon-green {
    background: #30D158;
}

.icon-orange {
    background: #FF9F0A;
}

.tile-content {
    padding: 24px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* --- Project List inside Tile --- */
.mini-project-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mini-project-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.mini-project-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.mini-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--system-gray5);
}

/* --- Research Themes Mini Grid --- */
.research-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
}

.badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* --- Profile Specifics --- */
.profile-memoji {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    background-color: var(--system-gray2);
    /* Placeholder color if image fails */
    overflow: hidden;
}

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

.profile-name {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(120deg, #fff, #a0a0a0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.action-button {
    background: var(--system-blue);
    color: white;
    padding: 10px 24px;
    border-radius: 20px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.action-button:hover {
    background: #0077ED;
    /* Darker blue */
    transform: scale(1.05);
}

/* --- Utilities --- */
.text-sm {
    font-size: 0.85rem;
}

.text-right {
    text-align: right;
}

.mt-auto {
    margin-top: auto;
}