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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --secondary: #10b981;
    --secondary-gradient: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --accent: #f59e0b;
    --danger: #ef4444;
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-alt: #f1f5f9;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    --radius-sm: 0.5rem;
    --radius: 1rem;
    --radius-lg: 1.5rem;
    --sidebar-width: 280px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-alt: #0f172a;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-xl);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

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

.logo-icon {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--primary-gradient);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    background: var(--primary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.logo-text span {
    color: var(--primary);
    background: none;
}

.sidebar-close {
    display: none;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: left;
}

.nav-item i {
    width: 1.5rem;
    font-size: 1.125rem;
}

.nav-item span {
    flex: 1;
    font-weight: 600;
}

.nav-item small {
    font-size: 0.65rem;
    opacity: 0.7;
}

.nav-item:hover {
    background: var(--surface-alt);
    transform: translateX(5px);
}

.nav-item.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.theme-toggle-sidebar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    width: 100%;
    color: var(--text);
    font-weight: 500;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 1.5rem;
}

.floating-theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--border);
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.floating-theme-toggle:hover {
    transform: scale(1.1);
}

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--primary-gradient);
    color: white;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
}

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    padding-bottom: calc(0.5rem + var(--safe-bottom));
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    border-radius: var(--radius);
}

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

.bottom-nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
}

/* Sections */
.content-section {
    display: none;
    animation: fadeInUp 0.3s ease;
}

.content-section.active {
    display: block;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

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

.section-header {
    margin-bottom: 1.5rem;
}

.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 1rem;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.section-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--primary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    margin-bottom: 0.5rem;
}

.section-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Calculator Card */
.calculator-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s, box-shadow 0.2s;
}

.calculator-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.card-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.group-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.group-selector label {
    font-weight: 500;
    color: var(--text-muted);
}

.group-select {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    font-size: 0.875rem;
}

/* Subjects Grid */
.subjects-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    max-height: 450px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.subjects-grid::-webkit-scrollbar {
    width: 6px;
}

.subjects-grid::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 10px;
}

.subjects-grid::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.subject-item {
    display: grid;
    grid-template-columns: 2fr 1fr auto auto;
    gap: 0.75rem;
    align-items: center;
    background: var(--surface-alt);
    border-radius: var(--radius);
    padding: 0.75rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

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

.subject-item input {
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 0.875rem;
}

.subject-item .marks-input {
    width: 100%;
}

.fourth-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    white-space: nowrap;
    color: var(--text-muted);
}

.fourth-label input {
    width: auto;
    margin: 0;
}

.remove-subj {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: 2rem;
    transition: opacity 0.2s;
}

.remove-subj:hover {
    opacity: 0.8;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-add,
.btn-calculate,
.btn-reset {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.btn-add {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-calculate {
    background: var(--primary-gradient);
    color: white;
    flex: 1;
}

.btn-reset {
    background: var(--danger-gradient);
    color: white;
}

.btn-add:hover,
.btn-calculate:hover,
.btn-reset:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
}

/* Result Card */
.result-card {
    margin-top: 1.5rem;
    padding: 2rem;
    background: var(--primary-gradient);
    border-radius: var(--radius-lg);
    text-align: center;
    animation: bounceIn 0.5s ease;
    color: white;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }

    50% {
        transform: scale(1.02);
    }

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

.result-gpa {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1;
}

.result-grade {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

/* CGPA Iframe */
.cgpa-wrapper {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.cgpa-iframe {
    width: 100%;
    height: 650px;
    border: none;
}

.iframe-footer {
    padding: 1rem;
    text-align: center;
    border-top: 1px solid var(--border);
}

.iframe-footer a {
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Grade Table */
.grade-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.grade-table-wrapper {
    overflow-x: auto;
}

.grade-table {
    width: 100%;
    border-collapse: collapse;
}

.grade-table th,
.grade-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.grade-table th {
    background: var(--primary-gradient);
    color: white;
    font-weight: 600;
}

.grade-table tr:hover {
    background: var(--surface-alt);
}

.fail-row {
    background: rgba(239, 68, 68, 0.1);
}

.success-text {
    color: var(--secondary);
    font-weight: 600;
}

.danger-text {
    color: var(--danger);
    font-weight: 600;
}

.grade-info {
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    background: var(--surface-alt);
}

.info-box {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: var(--radius);
}

.info-box i {
    font-size: 1.5rem;
    color: var(--primary);
}

.info-box strong {
    display: block;
    margin-bottom: 0.25rem;
}

.info-box p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* About Section */
.about-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.about-header {
    background: var(--primary-gradient);
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.about-avatar {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
}

.about-title h2 {
    color: white;
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
}

.about-title p {
    color: rgba(255, 255, 255, 0.9);
}

.about-content {
    padding: 2rem;
}

.about-bio {
    margin-bottom: 2rem;
}

.about-bio h3,
.about-skills h3,
.about-education h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.about-bio p {
    color: var(--text-muted);
    line-height: 1.6;
}

.about-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface-alt);
    border-radius: var(--radius);
}

.stat-item i {
    font-size: 2rem;
    color: var(--primary);
}

.stat-item strong {
    font-size: 1.5rem;
    display: block;
    color: var(--text);
}

.stat-item span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.skills-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.skill-tag {
    padding: 0.5rem 1rem;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 2rem;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.skill-tag:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.education-item {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--surface-alt);
    border-radius: var(--radius);
}

.education-item strong {
    display: block;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.education-item p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.about-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.about-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.about-btn.portfolio {
    background: var(--primary-gradient);
    color: white;
}

.about-btn.github {
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--border);
}

.about-btn.linkedin {
    background: #0077b5;
    color: white;
}

.about-btn.email {
    background: var(--danger-gradient);
    color: white;
}

.about-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 260px;
    }

    .main-content {
        margin-left: 260px;
        padding: 1.5rem;
    }

    .section-header h1 {
        font-size: 1.75rem;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 85%;
        max-width: 320px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: flex;
        background: var(--surface-alt);
        border: none;
        width: 2rem;
        height: 2rem;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: var(--text-muted);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 5rem;
        padding-bottom: 5rem;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .bottom-nav {
        display: flex;
    }

    .floating-theme-toggle {
        bottom: 5rem;
        right: 1rem;
    }

    .subject-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .fourth-label {
        justify-content: flex-start;
    }

    .remove-subj {
        width: 100%;
        padding: 0.625rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn-calculate {
        order: -1;
    }

    .card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .group-selector {
        justify-content: space-between;
    }

    .section-header h1 {
        font-size: 1.5rem;
    }

    .result-gpa {
        font-size: 3rem;
    }

    .cgpa-iframe {
        height: 500px;
    }

    .grade-info {
        grid-template-columns: 1fr;
    }

    .about-header {
        flex-direction: column;
        text-align: center;
    }

    .about-title {
        text-align: center;
    }

    .about-content {
        padding: 1.5rem;
    }

    .about-stats {
        grid-template-columns: 1fr;
    }

    .about-links {
        justify-content: center;
    }

    .stat-item {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 0.75rem;
        padding-top: 4.5rem;
        padding-bottom: 5rem;
    }

    .section-header h1 {
        font-size: 1.25rem;
    }

    .calculator-card {
        padding: 1rem;
    }

    .card-header h3 {
        font-size: 1rem;
    }

    .group-select {
        font-size: 0.8rem;
        padding: 0.5rem;
    }

    .btn-add,
    .btn-calculate,
    .btn-reset {
        padding: 0.75rem;
        font-size: 0.8rem;
    }

    .result-gpa {
        font-size: 2.5rem;
    }

    .grade-table th,
    .grade-table td {
        padding: 0.625rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .main-content {
        padding-top: 4rem;
    }

    .subjects-grid {
        max-height: 250px;
    }

    .cgpa-iframe {
        height: 350px;
    }
}

@media (min-width: 1440px) {
    .main-content {
        max-width: 1400px;
        margin-left: auto;
        margin-right: auto;
        padding: 2rem 3rem;
    }

    .sidebar {
        left: calc((100% - 1400px) / 2);
    }

    .main-content {
        margin-left: calc(var(--sidebar-width) + ((100% - 1400px) / 2));
    }
}

@media (hover: none) and (pointer: coarse) {

    .nav-item:hover,
    .btn-add:hover,
    .btn-calculate:hover,
    .btn-reset:hover {
        transform: none;
    }

    button:active {
        transform: scale(0.97);
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {

    .sidebar,
    .bottom-nav,
    .floating-theme-toggle,
    .mobile-menu-btn,
    .action-buttons {
        display: none;
    }

    .main-content {
        margin: 0;
        padding: 0;
    }

    .content-section {
        display: block !important;
    }
}



/* APK Download Section Styling */
.apk-download-card {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--card-bg, rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.apk-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 1rem;
}

.apk-header i {
    font-size: 1.5rem;
    color: #3b82f6; /* Modern Blue */
}

.apk-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.apk-body p {
    font-size: 0.95rem;
    opacity: 0.8;
    margin-bottom: 1.5rem;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
    color: white;
}

.apk-warning {
    margin-top: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #f59e0b; /* Amber/Warning color */
    background: rgba(245, 158, 11, 0.1);
    padding: 8px 12px;
    border-radius: 8px;
}