:root {
    --bg-dark: #0a0a0a;
    --bg-card: #121212;
    --bg-alt: #0f0f0f;
    --accent: #4dabff;
    --text-main: #e0e0e0;
    --text-dim: #a0a0a0;
    --white: #ffffff;
    --border: #222;
    --transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.light-theme {
    --bg-dark: #f8f9fa;
    --bg-card: #ffffff;
    --bg-alt: #f1f3f5;
    --accent: #2563eb;
    --text-main: #1a1a1a;
    --text-dim: #4b5563;
    --white: #ffffff;
    --border: #e5e7eb;
}

.sakura-theme {
    --bg-dark: #1a0e15;
    --bg-card: #241521;
    --bg-alt: #1f1119;
    --accent: #ff8fab;
    --text-main: #ffeef2;
    --text-dim: #d9a8b8;
    --white: #ffffff;
    --border: #3d2532;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    padding-top: 60px;
    transition: background-color 0.5s ease, color 0.5s ease;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes glow {
    0% { filter: drop-shadow(0 0 5px rgba(77, 173, 255, 0.2)); }
    50% { filter: drop-shadow(0 0 15px rgba(77, 173, 255, 0.5)); }
    100% { filter: drop-shadow(0 0 5px rgba(77, 173, 255, 0.2)); }
}

.animate-fade-in {
    animation: fadeIn 1s ease-out forwards;
}

.animate-slide-up {
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
}

.stagger-1 { animation-delay: 0.2s; }
.stagger-2 { animation-delay: 0.4s; }
.stagger-3 { animation-delay: 0.6s; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Navigation & Theme Picker */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 60px;
}

.light-theme nav {
    background: rgba(248, 249, 250, 0.8);
}

.sakura-theme nav {
    background: rgba(26, 14, 21, 0.85);
}

.nav-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.nav-logo img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.nav-logo span {
    font-family: 'Fira Code', monospace;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-main);
    font-size: 0.9rem;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-dim);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

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

.nav-cta {
    background: var(--accent);
    color: var(--bg-dark) !important;
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    font-weight: 600 !important;
}

/* Theme Picker Dropdown */
.theme-picker {
    position: relative;
}

.theme-toggle {
    list-style: none;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    color: var(--text-dim);
    background: transparent;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--text-main);
}

.theme-dropdown {
    position: absolute;
    top: 130%;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem;
    width: 190px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 1100;
    display: none;
    flex-direction: column;
    gap: 0.35rem;
}

.theme-dropdown.open {
    display: flex;
}

.theme-option {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-main);
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: var(--transition);
    width: 100%;
}

.theme-option:hover {
    border-color: var(--accent);
    background: rgba(255, 143, 171, 0.08);
}

.theme-option[aria-pressed="true"] {
    background: var(--accent);
    color: var(--bg-dark);
    font-weight: 600;
}

/* Sakura petal shower */
.petal-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 900;
    overflow: hidden;
    display: none;
}

.sakura-theme .petal-layer {
    display: block;
}

.petal {
    position: absolute;
    top: -10%;
    width: 14px;
    height: 14px;
    background: radial-gradient(circle at 30% 30%, #ffd6e2, #ff8fab 70%);
    border-radius: 150% 0 150% 0;
    opacity: 0.85;
    animation: petal-fall linear infinite, petal-sway ease-in-out infinite;
    will-change: transform;
}

@keyframes petal-fall {
    from { transform: translateY(-10vh) rotate(0deg); }
    to { transform: translateY(110vh) rotate(360deg); }
}

@keyframes petal-sway {
    0%, 100% { margin-left: 0; }
    50% { margin-left: 40px; }
}

.circle-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    transition: var(--transition);
}

.overlap {
    margin-left: -20px;
    z-index: 2;
    border-color: var(--accent);
}

.mascot-logo {
    width: 80px;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(77, 173, 255, 0.3));
}

.hero h1 {
    font-size: 4rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 1rem;
    letter-spacing: -1px;
}

.hero h1 .accent {
    color: var(--accent);
}

.accent {
    color: var(--accent);
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-dim);
    margin-bottom: 2.5rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-btns {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn {
    padding: 1rem 2rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.btn.primary {
    background: var(--accent);
    color: var(--bg-dark);
}

.btn.secondary {
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

/* Sections */
.section {
    padding: 8rem 0;
}

.bg-alt {
    background-color: var(--bg-alt);
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    color: var(--text-main);
    margin-bottom: 4rem;
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 3px;
    background: var(--accent);
}

/* About Grid */
.about-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.about-card {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.about-card:hover {
    border-color: var(--accent);
    transform: translateY(-5px);
}

.about-card h3 {
    color: var(--text-main);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.about-card p {
    color: var(--text-dim);
}

/* Projects Section Intro */
.section-intro {
    text-align: center;
    color: var(--text-dim);
    max-width: 620px;
    margin: -2.5rem auto 3rem;
    font-size: 1.05rem;
}

.section-intro a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.section-intro a:hover {
    text-decoration: underline;
}

/* Repo metadata strip on project cards */
.repo-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.78rem;
    color: var(--text-dim);
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.meta-item a {
    color: var(--text-dim);
    text-decoration: none;
    transition: var(--transition);
}

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

.lang-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
}

.project-card {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.project-card:hover {
    border-color: var(--accent);
    background: #161616;
}

.light-theme .project-card:hover {
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.sakura-theme .project-card:hover {
    background: #2a1a26;
}

.project-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
}

.project-card h3 {
    color: var(--text-main);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.project-card p {
    color: var(--text-dim);
    margin-bottom: 2rem;
    flex-grow: 1;
}

.project-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #222;
    color: var(--accent);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 1rem;
    align-self: flex-start;
}

.light-theme .badge {
    background: #eef2ff;
}

.sakura-theme .badge {
    background: #3d2532;
}


/* Project Detail Pages */
.project-detail-header {
    text-align: center;
    margin-bottom: 4rem;
}

.detail-logo {
    width: 140px;
    height: 140px;
    border-radius: 24px;
    margin-bottom: 1rem;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    object-fit: contain;
    background: radial-gradient(circle, #1a1a1a 0%, #0a0a0a 100%);
    padding: 10px;
    border: 1px solid var(--border);
    animation: glow 4s infinite ease-in-out;
}

.detail-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.detail-subtitle {
    font-size: 1.2rem;
    color: var(--text-dim);
    margin-bottom: 2rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 3rem;
}

@media (max-width: 768px) {
    .detail-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

.content-block {
    margin-bottom: 3rem;
}

.content-block h2 {
    color: var(--text-main);
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.markdown-content {
    color: var(--text-dim);
    font-size: 1.1rem;
}

.code-section {
    background: #000;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 1.5rem;
}

.code-header {
    background: #1a1a1a;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    font-family: 'Fira Code', monospace;
}

.code-section pre {
    padding: 1.5rem;
    color: #a9b7c6;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
}

.sidebar-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-card .btn {
    width: 100%;
    text-align: center;
    display: block;
}

.sidebar-card h3 {
    color: var(--text-main);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.sidebar-card ul {
    list-style: none;
    padding: 0;
    color: var(--text-dim);
}

.sidebar-card li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.project-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.project-logo {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: contain;
    background: radial-gradient(circle, #1a1a1a 0%, #0a0a0a 100%);
    padding: 5px;
    border: 1px solid var(--border);
    animation: glow 3s infinite ease-in-out;
}

.project-actions {
    display: flex;
    gap: 1rem;
    margin-top: auto;
}

.footer-container {
    max-width: 600px;
    margin: 0 auto;
}

.footer-logos {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.footer-logos img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

footer p {
    color: var(--text-dim);
    font-size: 0.9rem;
}

.footer-credit {
    margin-top: 1rem;
    font-size: 0.8rem;
    opacity: 0.6;
    font-family: 'Fira Code', monospace;
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 2.5rem;
    }
    .nav-links a:not(.nav-cta) {
        display: none;
    }
    .nav-links {
        gap: 0.75rem;
    }
    .theme-dropdown {
        width: 170px;
    }
    .logo-group {
        gap: 10px;
    }
    .container {
        padding: 0 1.25rem;
    }
}

/* ============ Hero stats bar (index) ============ */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.stat-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.5rem 1.1rem;
    border-radius: 20px;
    font-family: 'Fira Code', monospace;
    font-size: 0.82rem;
    color: var(--text-dim);
    transition: var(--transition);
}

.stat-item:hover {
    border-color: var(--accent);
    color: var(--text-main);
}

.stat-item .view-counter {
    color: var(--accent);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ============ Tech Stack section (index) ============ */
.stack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.stack-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    transition: var(--transition);
}

.stack-card:hover {
    border-color: var(--accent);
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.light-theme .stack-card:hover {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

.stack-card.main {
    border-color: var(--accent);
    background: linear-gradient(160deg, rgba(77, 173, 255, 0.09), transparent 55%);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.light-theme .stack-card.main {
    background: linear-gradient(160deg, rgba(37, 99, 235, 0.07), transparent 55%);
}

.stack-icon {
    font-size: 2.2rem;
    line-height: 1;
}

.stack-card h3 {
    color: var(--text-main);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.stack-card p {
    color: var(--text-dim);
    font-size: 0.92rem;
    flex-grow: 1;
}

.stack-flag {
    font-family: 'Fira Code', monospace;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    background: var(--accent);
    color: var(--bg-dark);
    padding: 0.18rem 0.55rem;
    border-radius: 20px;
    text-transform: uppercase;
}

.code-card {
    background: #000;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.code-card .code-header {
    background: #151515;
    padding: 0.5rem 0.9rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.7rem;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-card pre {
    padding: 1rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.78rem;
    color: #a9b7c6;
    overflow-x: auto;
    line-height: 1.55;
    margin: 0;
}

.backend-note {
    margin-top: 2.5rem;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    color: var(--text-dim);
    font-size: 0.9rem;
    text-align: center;
    font-family: 'Fira Code', monospace;
}

.backend-note strong {
    color: var(--text-main);
}

.backend-note code {
    color: var(--accent);
    background: rgba(77, 173, 255, 0.08);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}

/* ============ Visitor counter (footer, all pages) ============ */
.footer-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.4rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.82rem;
}

.counter-label {
    color: var(--text-dim);
}

.counter-value {
    color: var(--accent);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 2ch;
}

/* ============ Project card badges ============ */
.badge.flagship {
    background: var(--accent);
    color: var(--bg-dark);
}

.badge.deprecated {
    background: #333;
    color: #999;
}

.light-theme .badge.deprecated {
    background: #e5e7eb;
    color: #6b7280;
}

.sakura-theme .badge.deprecated {
    background: #4a2a33;
    color: #c89aa8;
}

@media (max-width: 768px) {
    .stack-grid {
        grid-template-columns: 1fr;
    }
}
