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

:root {
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #999999;
    --accent-red: #dc2626;
    --accent-red-dark: #991b1b;
    --border-color: #333333;
    --shadow: rgba(0, 0, 0, 0.8);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    line-height: 1.7;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
    box-sizing: border-box;
}

/* Header */
header {
    background: var(--bg-primary);
    padding: 50px 20px 40px;
    border-bottom: 1px solid var(--border-color);
}

.header-grid {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 40px;
}

.header-left {
    flex: 1;
}

.header-right {
    display: flex;
    align-items: flex-start;
}

header h1 {
    font-size: 3rem;
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--text-primary);
    letter-spacing: -0.8px;
    line-height: 1.1;
}

header .subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 300;
}

.team-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 300;
    margin: 0;
}

.header-links {
    display: flex;
    gap: 40px;
    text-align: right;
}

.header-link-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.link-label {
    font-size: 0.75rem;
    color: var(--text-primary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.link-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.link-items a {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
    font-weight: 300;
}

.link-items a:hover {
    color: var(--accent-red);
}

.link-items svg {
    opacity: 0.8;
}

/* Sticky Navigation */
.sticky-nav {
    position: sticky;
    top: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    padding: 0;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: center;
    gap: 0;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    padding: 16px 20px;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
    letter-spacing: 0.3px;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    text-decoration: none;
}

.nav-link.active {
    color: var(--accent-red);
    border-bottom-color: var(--accent-red);
}

/* Hero Section */
.hero-section {
    padding: 40px 20px;
    text-align: left;
}

.overview-description {
    margin: 0 0 1.5rem 0;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.system-description {
    margin: 0 0 2rem 0;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-secondary);
    font-weight: 300;
}

.overview-media-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}

.overview-image {
    width: 100%;
}

.hero-image {
    max-width: 100%;
    width: 100%;
    margin: 0;
    display: block;
    border-radius: 8px;
}

.overview-video {
    width: 100%;
}

.overview-video iframe {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
}

.system-flow {
    max-width: 700px;
    margin: 0 0 1.5rem 0;
    padding-left: 25px;
    font-size: 0.95rem;
    font-weight: 300;
}

.system-flow li {
    margin-bottom: 8px;
}

/* Section Styling */
section {
    padding: 40px 20px;
    margin: 0;
}

.requirements-section {
    padding: 40px 20px;
}

.section-header {
    text-align: left;
    margin-bottom: 30px;
}

.section-header h2 {
    font-size: 2rem;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.section-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 300;
    margin: 0;
}

h2 {
    font-size: 1.75rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.4px;
    text-align: left;
}

h3 {
    font-size: 1.1rem;
    margin: 2rem 0 1.5rem 0;
    color: var(--text-primary);
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

/* Text Content Width for Readability */
p {
    margin-bottom: 1.25rem;
}

p:last-child {
    margin-bottom: 0;
}

/* Video Container */
.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    max-width: 600px;
    margin: 0 auto;
    border-radius: 8px;
    width: 100%;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Image Grid - Instagram Style */
.img-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2px;
    margin: 20px 0;
    width: 100%;
}

.img-grid-item {
    position: relative;
    width: 100%;
    padding-top: 100%; /* Square aspect ratio */
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-secondary);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.img-grid-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease, transform 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.img-grid-item:hover img {
    opacity: 0.7;
    transform: scale(1.05);
}

/* Large Image Grid - For System Diagrams */
.img-grid-large {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
    margin: 20px 0;
    width: 100%;
}

.img-grid-item-large {
    position: relative;
    width: 100%;
    padding-top: 100%; /* Square aspect ratio - double height */
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-secondary);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.img-grid-item-large img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease, transform 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.img-grid-item-large:hover img {
    opacity: 0.7;
    transform: scale(1.05);
}

/* Lightbox Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    margin: auto;
    position: relative;
    animation: zoomIn 0.3s ease;
}

.modal-content img {
    width: 100%;
    height: auto;
    max-height: 90vh;
    object-fit: contain;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: var(--text-primary);
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    z-index: 1001;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--accent-red);
}

.modal-caption {
    color: var(--text-primary);
    text-align: center;
    padding: 0 20px 20px 20px;
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.3px;
}

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

@keyframes zoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Block Diagram */
.block-diagram {
    margin: 0;
}

.block-diagram img {
    max-width: 100%;
    width: 100%;
    max-width: 700px;
}

/* Lists */
ul, ol {
    margin: 20px 0;
    padding-left: 30px;
}

li {
    margin: 10px 0;
    color: var(--text-secondary);
    font-weight: 300;
}

li strong {
    color: var(--text-primary);
    font-weight: 400;
}

/* Requirements Sections */
.requirements {
    background: var(--bg-secondary);
    padding: 25px;
    margin: 20px 0;
    border-left: 2px solid var(--accent-red);
}

.requirements h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    font-size: 1rem;
}

.requirements p {
    color: var(--text-secondary);
    margin: 10px 0;
    font-weight: 300;
}

/* Requirements Columns Layout */
.requirements-columns {
    display: flex;
    gap: 60px;
    margin-top: 40px;
    position: relative;
}

.requirements-columns::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-color);
    transform: translateX(-50%);
}

.requirements-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.column-header {
    font-size: 1rem !important;
    font-weight: 600;
    color: var(--accent-red);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 20px 0 !important;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-red);
}

.req-card {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.req-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-red);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.req-card:hover {
    transform: translateY(-4px);
    border-color: rgba(220, 38, 38, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.req-card:hover::before {
    transform: scaleY(1);
}

.req-number {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-red);
    letter-spacing: 1px;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.req-card h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1.3;
    letter-spacing: -0.2px;
}

.req-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.req-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.req-content p {
    color: var(--text-secondary);
    font-weight: 300;
    font-size: 0.9rem;
    line-height: 1.7;
    margin: 0;
}

/* Conclusion Section */
.conclusion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.conclusion-card {
    background: var(--bg-secondary);
    padding: 18px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.conclusion-card h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 0.9rem;
    font-weight: 500;
}

.conclusion-card ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.conclusion-card li {
    padding-left: 18px;
    position: relative;
    font-weight: 300;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 6px;
}

.conclusion-card li:last-child {
    margin-bottom: 0;
}

.conclusion-card li:before {
    content: "—";
    position: absolute;
    left: 0;
    color: var(--accent-red);
}

.conclusion-card ul ul {
    margin-top: 8px;
    margin-bottom: 8px;
}

/* Links */
a {
    color: var(--accent-red);
    text-decoration: none;
    transition: color 0.3s ease;
    font-weight: 400;
    -webkit-tap-highlight-color: rgba(220, 38, 38, 0.2);
}

a:hover {
    color: var(--accent-red-dark);
    text-decoration: underline;
}

a:active {
    opacity: 0.8;
}

/* Footer */
footer {
    background: var(--bg-primary);
    padding: 30px 20px;
    text-align: center;
    border-top: 1px solid var(--border-color);
    margin-top: 60px;
}

footer p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 300;
    margin: 0;
}

/* Definitions */
.def-card-single {
    background: var(--bg-secondary);
    padding: 20px 24px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.def-card-single h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-red);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.def-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 40px;
}

.def-item {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 12px;
    align-items: baseline;
}

.def-term {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: 'Courier New', Courier, monospace;
}

.def-desc {
    color: var(--text-secondary);
    font-weight: 300;
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Responsive Design */
@media (max-width: 968px) {
    .requirements-columns {
        flex-direction: column;
        gap: 40px;
    }

    .requirements-columns::before {
        display: none;
    }

    .def-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .def-item {
        grid-template-columns: 100px 1fr;
        gap: 12px;
    }
}

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

    .header-grid {
        flex-direction: column;
        gap: 24px;
        align-items: center;
    }

    .header-left {
        text-align: center;
    }

    .header-links {
        gap: 30px;
        text-align: left;
    }

    .nav-container {
        padding: 0 8px;
        gap: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-link {
        font-size: 0.75rem;
        padding: 14px 12px;
        white-space: nowrap;
    }

    header {
        padding: 30px 16px 24px;
    }

    header h1 {
        font-size: 2rem;
        margin-bottom: 8px;
    }

    header .subtitle {
        font-size: 0.9rem;
        margin-bottom: 12px;
    }

    header .team-info {
        font-size: 0.85rem;
        margin-top: 12px;
    }

    h2 {
        font-size: 1.4rem;
        margin-bottom: 16px;
    }
    
    .section-header h2 {
        font-size: 1.4rem;
    }

    .section-header {
        margin-bottom: 24px;
    }

    .section-subtitle {
        font-size: 0.85rem;
    }

    section {
        padding: 30px 16px;
    }

    .requirements-section {
        padding: 30px 16px;
    }

    .hero-section {
        padding: 30px 16px;
    }

    .overview-media-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .overview-video iframe {
        max-height: 300px;
    }

    .overview-description {
        font-size: 0.95rem;
        line-height: 1.6;
    }

    .system-description {
        font-size: 0.9rem;
    }

    .img-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1px;
        margin: 16px 0;
    }

    .img-grid-large {
        grid-template-columns: 1fr;
    }

    .conclusion-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin: 16px 0;
    }

    .def-card-single {
        padding: 18px;
        margin-bottom: 30px;
    }

    .def-card-single h3 {
        font-size: 0.75rem;
        margin-bottom: 16px;
    }

    .def-item {
        grid-template-columns: 90px 1fr;
        gap: 10px;
    }

    .def-term {
        font-size: 0.8rem;
    }

    .def-desc {
        font-size: 0.8rem;
    }
    
    .req-card {
        padding: 18px;
    }

    .req-number {
        font-size: 0.7rem;
        margin-bottom: 8px;
    }

    .req-card h3 {
        font-size: 0.95rem;
        margin-bottom: 14px;
    }

    .req-content {
        gap: 10px;
    }

    .req-label {
        font-size: 0.7rem;
    }

    .req-content p {
        font-size: 0.85rem;
        line-height: 1.6;
    }
    
    .conclusion-card {
        padding: 16px;
    }

    .conclusion-card h4 {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }

    .conclusion-card li {
        font-size: 0.8rem;
        margin-bottom: 5px;
    }

    .video-container {
        margin: 16px 0;
    }

    .block-diagram {
        gap: 16px;
    }

    .block-diagram img {
        border-radius: 6px;
    }

    footer {
        padding: 24px 16px;
        margin-top: 24px;
    }

    footer .team-section h2,
    footer .repo-link h2 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    footer .team-list {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }

    footer .team-list li {
        font-size: 0.85rem;
    }

    .modal-close {
        top: 10px;
        right: 16px;
        font-size: 28px;
    }

    .modal-content {
        max-width: 95%;
        max-height: 85%;
    }

    .modal-caption {
        font-size: 0.8rem;
        padding: 12px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.25rem;
    }

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

    .img-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    section {
        padding: 24px 12px;
    }

    .requirements-section {
        padding: 28px 12px;
    }

    .req-card {
        padding: 16px;
    }

    .def-card {
        padding: 14px;
    }

    .conclusion-card {
        padding: 14px;
    }
}

/* Smooth Scroll */
html {
    scroll-behavior: smooth;
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
    /* Prevent text overflow */
    p, li, dd, dt {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Improve touch targets */
    .img-grid-item,
    .req-card,
    .def-card,
    .conclusion-card {
        min-height: 44px; /* Minimum touch target size */
    }

    /* Better list spacing on mobile */
    ol, ul {
        padding-left: 20px;
    }

    li {
        margin-bottom: 6px;
    }

    /* Ensure images don't overflow */
    img {
        max-width: 100%;
        height: auto;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    header h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.15rem;
    }

    .img-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .req-card,
    .def-card {
        padding: 12px;
    }
}
