:root,
[data-theme="wine"] {
    --bg-dark: #1a080c;
    /* Deep dark wine red */
    --bg-card: rgba(55, 15, 25, 0.7);
    /* Translucent wine card */
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #fecdd3;
    /* Rose tinted secondary text */
    --accent-wine: #e11d48;
    /* Vibrant wine red */
    --accent-wine-hover: #be123c;
    --accent-orange: #f59e0b;
    --accent-orange-hover: #d97706;
    --success: #10b981;
    --danger: #ef4444;

    --bg-grad-1: rgba(142, 22, 40, 0.15);
    --bg-grad-2: rgba(225, 29, 72, 0.08);
    --bg-grad-3: rgba(26, 8, 12, 1);
    --bg-grad-4: rgba(40, 10, 15, 1);
    --header-bg: rgba(40, 10, 15, 0.7);
}

[data-theme="obsidian"] {
    --bg-dark: #0a0a0a;
    --bg-card: rgba(20, 20, 20, 0.8);
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --accent-wine: #dc2626;
    --accent-wine-hover: #b91c1c;
    --bg-grad-1: rgba(220, 38, 38, 0.15);
    --bg-grad-2: rgba(220, 38, 38, 0.08);
    --bg-grad-3: #000000;
    --bg-grad-4: #0f0f0f;
    --header-bg: rgba(10, 10, 10, 0.8);
}

[data-theme="navy"] {
    --bg-dark: #020617;
    --bg-card: rgba(15, 23, 42, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #bae6fd;
    --accent-wine: #0ea5e9;
    --accent-wine-hover: #0284c7;
    --bg-grad-1: rgba(14, 165, 233, 0.15);
    --bg-grad-2: rgba(2, 132, 199, 0.08);
    --bg-grad-3: #020617;
    --bg-grad-4: #0f172a;
    --header-bg: rgba(15, 23, 42, 0.8);
}

[data-theme="emerald"] {
    --bg-dark: #022c22;
    --bg-card: rgba(6, 78, 59, 0.4);
    --text-primary: #ecfdf5;
    --text-secondary: #a7f3d0;
    --accent-wine: #10b981;
    --accent-wine-hover: #059669;
    --bg-grad-1: rgba(16, 185, 129, 0.15);
    --bg-grad-2: rgba(5, 150, 105, 0.08);
    --bg-grad-3: #022c22;
    --bg-grad-4: #064e3b;
    --header-bg: rgba(2, 44, 34, 0.8);
}

[data-theme="spotlight"] {
    --bg-dark: #000000;
    --bg-card: rgba(15, 0, 0, 0.6);
    --text-primary: #ffffff;
    --text-secondary: #fca5a5;
    --accent-wine: #dc2626;
    --accent-wine-hover: #b91c1c;
    --header-bg: rgba(5, 0, 0, 0.8);
    --bg-grad-1: transparent;
    --bg-grad-2: transparent;
    --bg-grad-3: #000000;
    --bg-grad-4: #000000;
}

[data-theme="spotlight"] body {
    background: #000000;
    background-image: radial-gradient(circle 400px at var(--cursor-x, 50%) var(--cursor-y, -100%), rgba(255, 20, 20, 0.5), transparent 80%);
    background-attachment: fixed;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 0% 0%, var(--bg-grad-1) 0%, transparent 40%),
        radial-gradient(circle at 100% 100%, var(--bg-grad-2) 0%, transparent 40%),
        linear-gradient(to bottom right, var(--bg-grad-3), var(--bg-grad-4));
    transition: background 0.4s ease, color 0.4s ease;
}

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

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 2.5rem;
    padding: 1.25rem 2rem;
    position: sticky;
    top: 1rem;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    transition: background 0.4s ease;
}

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

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

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

.time-container {
    display: flex;
    gap: 2rem;
}

.time-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.time-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

.time-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.25rem;
    color: var(--accent-orange);
    font-weight: 600;
}

section {
    margin-bottom: 3rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Table Styles */
.table-container {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow-x: auto;
}

.premium-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.premium-table th {
    background: rgba(255, 255, 255, 0.03);
    padding: 1.2rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    border-bottom: 1px solid var(--border-color);
}

.premium-table td {
    padding: 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
}

.premium-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* TAF Box */
.taf-container {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.taf-box {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
}

.taf-box h4 {
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
}

.taf-text {
    font-family: 'JetBrains Mono', monospace, Consolas, Courier;
    font-size: 0.85rem;
    white-space: pre-wrap;
    line-height: 1.6;
    color: var(--text-primary);
}

.taf-highlight {
    color: #fca5a5;
    font-weight: 700;
}

.taf-dimmed {
    opacity: 0.3;
}

/* Forecast Section */
.forecast-input-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
}

.search-group {
    display: flex;
    gap: 0.75rem;
    max-width: 500px;
}

.search-group.taf-search-group {
    max-width: 500px;
    min-width: 260px;
}

.search-group input {
    flex: 1;
}

.forecast-results {
    margin-top: 1.5rem;
    min-height: 100px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.forecast-item {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 1rem;
    border-left: 3px solid var(--accent-wine);
}

.forecast-time {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.forecast-temp {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.forecast-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.placeholder-text {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    font-style: italic;
}

/* NOTAM Results */
.notam-results {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notam-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.2rem;
    border-left: 3px solid var(--accent-orange);
}

.notam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.notam-icao {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-orange);
}

.notam-validity {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.08);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.notam-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
}

/* E6B Cards */
.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1.5rem;
    align-items: start;
}

.calc-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 480px;
    /* Ensure cards have consistent minimum height */
}

.calc-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03rem;
}

input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.7rem;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
    width: 100%;
}

input:focus {
    border-color: var(--accent-wine);
    background: rgba(0, 0, 0, 0.4);
}

.result-display {
    margin-top: auto;
    padding-top: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.result-item .label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
}

.result-item .value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--accent-wine);
    text-align: right;
    word-break: break-all;
}

.result-item.highlight .value {
    color: var(--accent-orange);
    font-size: 1.25rem;
}

.btn-accent {
    background: var(--accent-orange);
    border: none;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-accent:hover {
    background: var(--accent-orange-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.tag-source {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
}

.tag-atis {
    background: rgba(142, 22, 40, 0.2);
    color: #e26377;
    border: 1px solid rgba(142, 22, 40, 0.3);
}

.tag-metar {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.tag-taf {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* GFA Section */
.gfa-link-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2.5rem 1.5rem;
    text-align: center;
}

.gfa-link-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    margin-right: auto;
}

#gfa-pacific-container {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    min-height: 200px;
}

@media (max-width: 992px) {
    .gfa-viewer-grid {
        grid-template-columns: 1fr !important;
    }
}

.gfa-btn {
    display: inline-flex;
    align-items: center;
    background: var(--accent-wine);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(225, 29, 72, 0.3);
}

.gfa-btn:hover {
    background: var(--accent-wine-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(225, 29, 72, 0.5);
}

/* Webcam Section */
.webcam-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.webcam-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    overflow: hidden;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 85vh;
    border-radius: 8px;
    object-fit: contain;
}

#modal-caption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: var(--text-primary);
    padding: 10px 0;
    height: 150px;
    font-size: 1.2rem;
}

.modal-close {
    position: absolute;
    top: 25px;
    right: 35px;
    color: var(--text-primary);
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.modal-close:hover,
.modal-close:focus {
    color: var(--accent-wine);
    text-decoration: none;
    cursor: pointer;
}

/* Image controls wrapper */
.gfa-image-wrapper {
    position: relative;
    width: 100%;
}

.enlarge-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.enlarge-btn:hover {
    background: var(--accent-wine);
}

.gfa-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.time-btn {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.time-btn.active {
    background: var(--accent-wine);
    color: white;
    border-color: var(--accent-wine);
}

@media (max-width: 768px) {
    html {
        font-size: 13px;
        /* Scales down all REM units (padding, fonts, sizes) to 'zoom out' the entire view */
    }

    .webcam-grid {
        grid-template-columns: 1fr;
    }

    .app-container {
        padding: 0.5rem;
    }

    header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
        padding: 1rem;
    }

    .header-controls {
        flex-wrap: wrap;
        width: 100%;
        gap: 1rem !important;
        justify-content: space-between;
    }

    .time-container {
        width: 100%;
        justify-content: space-between;
    }

    .calc-grid {
        grid-template-columns: 1fr;
    }

    .table-container {
        width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        border: none !important;
    }

    table {
        min-width: 600px;
        /* Force table to horizontally scroll instead of vertically breaking */
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 0.75rem 0.5rem;
        /* Tighter padding for mobile phones */
    }

    h1 {
        font-size: 1.5rem;
    }
}

/* Flight Limitation Go/No-Go Classes */
.status-legal {
    color: #ef4444;
    font-weight: 700;
    background: rgba(239, 68, 68, 0.15);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.status-club {
    color: #f97316;
    font-weight: 700;
    background: rgba(249, 115, 22, 0.15);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    border: 1px solid rgba(249, 115, 22, 0.4);
}

.status-circuits {
    color: #3b82f6;
    font-weight: 700;
    background: rgba(59, 130, 246, 0.15);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.status-personal {
    color: #eab308;
    font-weight: 700;
    background: rgba(234, 179, 8, 0.15);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    border: 1px solid rgba(234, 179, 8, 0.4);
}

/* Tag Inputs UI */
.tag-input-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.4);
    width: 100%;
    min-height: 42px;
}
.tag-input-container:focus-within {
    border-color: var(--accent-wine);
}
.tags-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.tag-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255,255,255,0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    color: white;
}
.tag-remove {
    cursor: pointer;
    width: 14px;
    height: 14px;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
}
.tag-remove:hover {
    opacity: 1;
    color: #ef4444;
}
.tag-input-field {
    flex: 1;
    min-width: 80px;
    background: transparent;
    border: none;
    color: white;
    font-size: 0.9rem;
    outline: none;
    padding: 0;
}

/* Module Hover Effects */
.table-container,
.taf-box,
.notam-item,
.forecast-input-card,
.gfa-link-card,
#gfa-pacific-container,
.webcam-card {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease;
}

/* Force bypass of cached inline overflow rules */
#weather-content,
#taf-content,
#notam-content,
#gfa-content,
#webcam-content,
#forecast-content,
#upperwind-content,
#navlog-content {
    overflow: visible !important;
}

.table-container:hover,
.taf-box:hover,
.notam-item:hover,
.forecast-input-card:hover,
.gfa-link-card:hover,
#gfa-pacific-container:hover,
.webcam-card:hover {
    transform: translateY(-2px) scale(1.005);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 10;
}