/* GlidePlan - Web UI Styles */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #059669;
    --success-hover: #047857;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --secondary-color: #6b7280;
    --secondary-hover: #4b5563;
    --background: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 12px 16px;
}

/* Header row: title centered, QR anchored to the right */
.modern-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 10px 16px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.header-text p {
    font-size: 0.9rem;
    margin: 0;
    color: var(--text-secondary);
}

.header-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-support-btn {
    text-decoration: none;
    font-size: 1.1rem;
}

.header-support-btn sl-button::part(base) {
    font-size: 1.05rem;
}

.header-support-btn sl-icon {
    font-size: 1.25rem;
}

/* Old header styles removed */
.header-row,
.header-spacer,
header,
.coffee-banner {
    display: none;
}

.coffee-banner a:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.coffee-qr {
    width: 120px;
    height: 120px;
    border-radius: 8px;
}

.coffee-text {
    font-size: 0.95rem;
}

header h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.site-logo {
    height: 80px;
    width: auto;
    display: block;
    margin: 0;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    background: var(--surface);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.file-actions, .waypoint-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Buttons — handled by Shoelace <sl-button> */

/* View-mode: read-only shared task banner */
.view-mode-banner {
    background: #0891b2;
    color: #fff;
    text-align: center;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.view-mode-banner a {
    color: #fde68a;
    text-decoration: none;
    font-weight: 600;
    margin-left: 4px;
}

.view-mode-banner a:hover { text-decoration: underline; }

/* Hide editor chrome in view mode */
body.view-mode .sidebar-file-row,
body.view-mode #airspace-filter-panel,
body.view-mode .wind-card,
body.view-mode .waypoint-search-card,
body.view-mode #task-clear-btn,
body.view-mode #task-share-btn {
    display: none !important;
}

/* Button sizes — handled by Shoelace <sl-button size="small"> */

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 14px;
    background: var(--surface);
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.modern-status {
    gap: 12px;
}

#status-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Map Toolbar — kept for legacy reference, now replaced by map-view sidebar */
.map-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--surface);
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.map-toolbar sl-button-group {
    flex-shrink: 0;
}

/* ──────────── Map View Sidebar Layout ──────────── */
.map-view {
    display: flex;
    gap: 12px;
    height: calc(100vh - 200px);
    min-height: 450px;
}

.map-sidebar {
    flex: 0 0 220px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 200px);
    padding-right: 2px;
}

.map-sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.map-sidebar-actions sl-button {
    width: 100%;
}

.map-file-card::part(body),
.map-tools-card::part(body) {
    padding: 8px 10px;
}

.map-content-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

.map-content-area .map-container {
    flex: 1;
    min-height: 400px;
    height: auto;
    max-height: none;
}

@media (max-width: 900px) {
    .map-view {
        flex-direction: column;
        height: auto;
        gap: 8px;
    }
    .map-sidebar {
        flex: none;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        overflow-y: visible;
    }
    .map-sidebar > sl-card {
        flex: 1 1 auto;
        min-width: 0;
    }
    .map-sidebar-actions {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }
    .map-sidebar-actions sl-button {
        width: auto;
    }
    .map-content-area .map-container {
        min-height: 350px;
        height: calc(100vh - 300px);
    }
}
/* ──────────── End Map View Sidebar Layout ──────────── */

/* ──────────── Waypoint Generation Card ──────────── */
.map-wpgen-card::part(body) {
    padding: 8px 10px;
}

.wpgen-area-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.wpgen-area-info {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--sl-color-primary-50);
    border: 1px solid var(--sl-color-primary-200);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 11px;
}

[data-theme="dark"] .wpgen-area-info {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.4);
}

.wpgen-area-text {
    flex: 1;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 10px;
    word-break: break-all;
}

.wpgen-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
    margin-top: 4px;
}

.wpgen-section-label small {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.wpgen-types {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 4px;
}

.wpgen-types sl-checkbox {
    font-size: 13px;
    --sl-font-size-small: 12px;
}

.wpgen-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

.wpgen-actions sl-button {
    width: 100%;
}

.wpgen-status {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.5;
    padding: 6px 8px;
    border-radius: 4px;
    background: var(--background);
    border: 1px solid var(--border);
}

.wpgen-status--success {
    border-color: var(--success-color);
    color: var(--success-color);
}

.wpgen-status--error {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.wpgen-status--info {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Cursor when drawing area selection */
.wpgen-selecting {
    cursor: crosshair !important;
}

/* ──────────── End Waypoint Generation Card ──────────── */

/* Old map-controls styles */
.map-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.map-controls-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 8px;
}

/* Shoelace button group styling */
sl-button-group::part(base) {
    gap: 2px;
}

/* Shoelace divider in toolbar */
sl-divider[vertical] {
    height: 32px;
}

/* Shoelace tooltip */
sl-tooltip {
    --max-width: 200px;
}

/* Main Tabs */
#main-tabs {
    --indicator-color: var(--primary-color);
}

/* Give all tab label icons a small right gap so they don't touch the text */
#main-tabs sl-tab i {
    margin-right: 5px;
}

#main-tabs::part(base) {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

#main-tabs::part(body) {
    min-height: 400px;
}

#main-tabs sl-tab-panel::part(base) {
    padding: 12px;
}

/* Waypoint actions within list tab */
sl-tab-panel .waypoint-actions {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

/* Table */
.table-container {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.waypoints-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.waypoints-table th {
    background-color: var(--background);
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.waypoints-table th:hover {
    background-color: var(--border);
}

.waypoints-table th i {
    margin-left: 5px;
    color: var(--text-secondary);
}

.waypoints-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
}

.waypoints-table tbody tr:hover {
    background-color: var(--background);
}

.waypoints-table tbody tr.selected {
    background-color: #dbeafe;
}

.airfield-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

.airfield-yes {
    color: var(--success-color);
}

.airfield-no {
    color: var(--text-secondary);
}

/* Map */
.map-container {
    /* Use viewport height minus space for header, controls, etc. */
    height: calc(100vh - 300px);
    min-height: 400px;
    max-height: 900px;
    border-radius: 6px;
    overflow: hidden;
    width: 100%;
}

.map-controls {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.map-controls-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

/* Dialogs — handled by Shoelace <sl-dialog> */
sl-dialog::part(panel) {
    border-radius: 8px;
}

sl-dialog::part(body) {
    padding: 20px 25px;
}

sl-dialog::part(footer) {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Modal tabs — handled by Shoelace <sl-tab-group> inside dialogs */
#modal-tabs {
    --indicator-color: var(--primary-color);
    margin-bottom: 10px;
}

#modal-tabs sl-tab-panel::part(base) {
    padding: 10px 0;
}

/* Form Groups in Modal */
.waypoint-form .form-group small {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.waypoint-form .input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.waypoint-form .input-group input {
    flex: 1;
}

.waypoint-form .input-group select {
    min-width: 60px;
}

.waypoint-form .input-group sl-button {
    white-space: nowrap;
}

/* Form */
.waypoint-form {
    padding: 25px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 25px;
    align-items: start;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0; /* Allow shrinking */
    position: relative;
    overflow: visible;
}

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 4px;
    display: block;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    background: white;
    position: relative;
    z-index: 1;
}

.form-group small {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.2;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-group {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.input-group input {
    flex: 2;
    min-width: 120px;
}

.input-group select {
    flex: 0 0 60px;
    width: 60px;
    min-width: 60px;
    max-width: 60px;
}

.input-group sl-button {
    white-space: nowrap;
    flex: 0 0 auto;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* OZ Info Button */
.oz-info-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary);
    font-size: 14px;
    padding: 0 4px;
    vertical-align: middle;
    opacity: 0.75;
    transition: opacity 0.15s;
}
.oz-info-btn:hover {
    opacity: 1;
}

/* OZ Info Popup */
.oz-info-popup {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
}
.oz-info-popup-inner {
    background: var(--surface);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    max-width: 780px;
    width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.oz-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
}
.oz-info-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 0 4px;
}
.oz-info-close:hover { color: var(--text-primary); }
.oz-info-body {
    overflow-y: auto;
    padding: 16px 20px;
}
.oz-info-note {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 0 12px;
}
.oz-compat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.oz-compat-table th,
.oz-compat-table td {
    padding: 7px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.oz-compat-table thead th {
    background: var(--surface-hover, #f5f5f5);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.oz-compat-table tbody tr:last-child td { border-bottom: none; }
.oz-compat-table .compat-ok { color: #2a8a2a; font-weight: 500; }
.oz-compat-table .compat-warn { color: #b07800; font-weight: 500; }

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    background-color: var(--surface);
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.loading-spinner i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .site-logo {
        height: 80px;
    }
    
    .file-actions,
    .waypoint-actions {
        justify-content: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .waypoints-table {
        font-size: 12px;
    }
    
    .waypoints-table th,
    .waypoints-table td {
        padding: 8px 4px;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 600; }
.text-success { color: var(--success-color); }
.text-error { color: var(--danger-color); }
.text-danger { color: var(--danger-color); }
.text-secondary { color: var(--text-secondary); }
.text-info { color: var(--text-secondary); }

html.sl-theme-dark .text-success { color: #34d399; }
html.sl-theme-dark .text-error,
html.sl-theme-dark .text-danger { color: #f87171; }

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Map Marker Popups */
.marker-popup {
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.marker-popup h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.marker-popup p {
    margin: 4px 0;
    color: var(--text-secondary);
}

.marker-popup sl-button {
    font-size: 12px;
}

.marker-popup sl-button i {
    font-size: 11px;
}

/* Detailed Popup Styling */
.detailed-popup {
    max-width: 320px;
    font-size: 13px;
}

.popup-title {
    margin: 0 0 12px 0 !important;
    font-size: 18px !important;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 6px;
}

.popup-section {
    margin-bottom: 15px;
}

.popup-section:last-of-type {
    margin-bottom: 10px;
}

.popup-section-title {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    background-color: var(--background);
    padding: 4px 8px;
    border-radius: 3px;
    border-left: 3px solid var(--primary-color);
}

.popup-field {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
    gap: 8px;
}

.field-label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 80px;
    flex-shrink: 0;
}

.field-value {
    color: var(--text-primary);
    font-weight: 400;
    text-align: right;
    word-break: break-word;
}

.popup-description {
    color: var(--text-primary);
    background-color: var(--background);
    padding: 8px;
    border-radius: 4px;
    border-left: 3px solid var(--secondary-color);
    font-style: italic;
    line-height: 1.5;
    max-height: 80px;
    overflow-y: auto;
}

.popup-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* Custom popup styling for Leaflet */
.waypoint-detailed-popup .leaflet-popup-content {
    margin: 15px;
    line-height: 1.4;
}

.waypoint-detailed-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

/* Waypoint Icons */
.waypoint-icon {
    background: none !important;
    border: none !important;
}

.waypoint-icon div {
    transition: transform 0.2s ease;
}

.waypoint-icon:hover div {
    transform: scale(1.1);
}

/* Legend Modal */
.legend-content {
    padding: 20px;
}

.legend-content p {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.legend-item:last-child {
    border-bottom: none;
}

.legend-icon {
    flex: 0 0 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.legend-label {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.legend-label strong {
    color: var(--primary-color);
    min-width: 20px;
    display: inline-block;
}

/* Responsive Design - Media Queries */

/* ──────────── Task Planner ──────────── */
.task-planner {
    display: flex;
    gap: 12px;
    height: calc(100vh - 200px);
    min-height: 450px;
    position: relative; /* needed for no-waypoints overlay */
}

/* No-waypoints overlay */
.task-no-waypoints-overlay {
    position: absolute;
    inset: 0;
    background: rgba(248, 250, 252, 0.94);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: 8px;
    backdrop-filter: blur(3px);
}

[data-theme="dark"] .task-no-waypoints-overlay {
    background: rgba(15, 23, 42, 0.94);
}

.task-no-waypoints-content {
    text-align: center;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.task-no-waypoints-content i {
    color: var(--text-secondary);
}

.task-no-waypoints-content h3 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.task-no-waypoints-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 320px;
    margin: 0;
}
/* ──────────── End No-waypoints overlay ──────────── */

.task-sidebar {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 400px;
    max-height: calc(100vh - 200px);
    padding-right: 2px;
}

/* File buttons row */
.sidebar-file-row {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.sidebar-file-row sl-button { flex-shrink: 0; }

.task-map-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}



.task-map-area .map-container {
    flex: 1;
    min-height: 400px;
}

/* Waypoint search dropdown */
.task-wp-results {
    position: absolute;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    max-height: 220px;
    overflow-y: auto;
    width: 100%;
}

.task-wp-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    transition: background 0.1s;
}

.task-wp-item:hover {
    background: var(--background);
}

.task-wp-meta {
    color: var(--text-secondary);
    font-size: 12px;
}

.task-wp-no-result {
    padding: 10px 12px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Task points list — scrollable, takes remaining sidebar space */
.task-points-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 120px;
}

.task-empty-msg {
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
}

.task-point-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 10px;
    flex-shrink: 0;
}

.task-point-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.task-point-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--primary-color);
    color: #fff;
}

.task-point-card:first-child .task-point-label { background: var(--success-color); }
.task-point-card:last-child .task-point-label { background: var(--danger-color); }

.task-point-name {
    font-weight: 600;
    font-size: 14px;
}

.task-point-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.task-point-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* Task summary */
.task-summary {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

.task-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    padding: 3px 0;
}

/* Export buttons */
.task-export-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-start;
}

/* Download dropdown — handled by Shoelace <sl-dropdown> */

/* Task section grouping */
.task-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Shoelace Card customization — sl-card */
sl-card {
    --border-radius: 10px;
    --border-width: 1px;
    --border-color: var(--border);
    --padding: 16px;
}

sl-card::part(header) {
    padding: 8px 16px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

sl-card::part(body) {
    padding: 10px 16px;
}

/* Prefix icons inside sl-input: space from left border and from following text */
sl-input::part(prefix) {
    padding-inline-start: 10px;
    padding-inline-end: 6px;
}

/* Waypoints count badge: gap between pin icon and count text */
#waypoint-count-badge i {
    margin-right: 4px;
}

.card-header-with-icon {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

.card-header-with-icon i {
    color: var(--primary-color);
    font-size: 15px;
}

/* Task Toolbar Card */
.task-toolbar-card {
    margin-bottom: 0;
}

.task-toolbar-card::part(body) {
    padding: 8px 10px;
}

.task-toolbar-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* Wind Card */
.wind-card {
    margin-bottom: 0;
}

.card-header-collapsible {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.card-header-collapsible .card-header-with-icon {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

.card-header-collapsible sl-icon-button {
    font-size: 14px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.card-header-collapsible sl-icon-button.collapsed {
    transform: rotate(-90deg);
}

.wind-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

/* Task Details Card */
.task-details-card {
    margin-bottom: 0;
}

.task-name-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-name-row sl-input {
    flex: 1;
}

.task-name-row sl-icon-button {
    font-size: 16px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.task-advanced-panel {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.task-option-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.task-option-field:last-child {
    margin-bottom: 0;
}

.task-option-field label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.task-option-field label i {
    font-size: 12px;
    opacity: 0.7;
}

/* Waypoint Search Card */
.waypoint-search-card {
    margin-bottom: 0;
}

.search-hint {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    padding: 5px 8px;
    background: var(--background);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.75;
}

.search-hint sl-icon {
    font-size: 14px;
}

/* Task Summary Card */
.task-summary-card {
    margin-bottom: 0;
}

.task-summary-stats {
    display: flex;
    flex-direction: row;
    gap: 6px;
    flex-wrap: wrap;
}

.task-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--background);
    border-radius: 6px;
    flex: 1 1 auto;
    min-width: 70px;
}

.task-stat i {
    font-size: 13px;
    color: var(--primary-color);
    width: 16px;
    text-align: center;
}

.task-stat label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 1px;
}

.task-stat strong {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Export Actions Card */
.export-actions-card {
    margin-bottom: 0;
    min-width: 0;
}

.export-actions-card::part(body) {
    padding: 8px 10px;
}

.export-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.export-actions-grid sl-button,
.export-actions-grid sl-dropdown {
    min-width: 0;
    width: 100%;
}

.export-actions-grid sl-dropdown sl-button {
    width: 100%;
}

/* Wind fields (3-column grid of sl-inputs) */
.wind-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

/* Options (sl-details) */
.task-options-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.task-options-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.task-options-row label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Native time/text inputs styled to match Shoelace */
.native-time-input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text-primary);
    text-align: right;
    width: 130px;
}

.native-time-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
/* Wind map control (Leaflet bottom-left) */
.wind-map-control {
    background: rgba(255,255,255,0.92);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.18);
    min-width: 44px;
    user-select: none;
}
.wmc-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}
.wmc-label {
    font-size: 10px;
    font-weight: 600;
    color: #2563eb;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* Airspace filter panel */
.airspace-filter-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.airspace-filename-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.airspace-filename {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}
.airspace-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}
.airspace-slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}
.airspace-slider-row label {
    white-space: nowrap;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}
/* Dual range slider */
.dual-range-wrap {
    flex: 1;
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
}
.dual-range-track-bg {
    position: absolute;
    left: 0; right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    pointer-events: none;
}
.dual-range-fill {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    background: var(--primary-color);
    border-radius: 2px;
    pointer-events: none;
    /* left and width set by JS */
    left: 0%; width: 40%;
}
.dual-range {
    position: absolute;
    width: 100%;
    height: 100%;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    padding: 0;
}
.dual-range::-webkit-slider-runnable-track {
    background: transparent;
    height: 4px;
}
.dual-range::-moz-range-track {
    background: transparent;
    height: 4px;
    border: none;
}
.dual-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    pointer-events: all;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid var(--surface, #fff);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    cursor: pointer;
    margin-top: -6px;
}
.dual-range::-moz-range-thumb {
    pointer-events: all;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid var(--surface, #fff);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    cursor: pointer;
}

/* Waypoint search wrapper */
.task-wp-search-wrap { display: flex; flex-direction: column; gap: 4px; }
.task-wp-search-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }

/* Multi-airspace floating tooltip */
.airspace-multi-tooltip {
    position: fixed;
    z-index: 9000;
    background: rgba(15, 23, 42, 0.95);
    color: #f1f5f9;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.5;
    max-width: 280px;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.astt-entry {
    padding: 2px 0;
}
.astt-name {
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 2px;
}
.astt-meta {
    color: #94a3b8;
    font-size: 11px;
}
.astt-time {
    color: #fbbf24;
    font-size: 11px;
    margin-top: 2px;
}
.astt-time .fas {
    margin-right: 3px;
}
.astt-flags {
    color: #f87171;
    font-size: 11px;
    font-weight: 600;
    margin-top: 2px;
}
.astt-sep {
    border: none;
    border-top: 1px solid rgba(148,163,184,0.2);
    margin: 6px 0;
}

/* Task QR modal body */
.task-qr-body {
    padding: 25px;
    text-align: center;
}

.task-qr-body p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.task-qr-canvas {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.task-qr-canvas canvas {
    border-radius: 8px;
    border: 1px solid var(--border);
}

.task-qr-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.task-qr-warn {
    color: var(--danger-color);
    font-size: 14px;
    padding: 16px;
    background: #fef2f2;
    border-radius: 8px;
}

/* Task map tooltip */
.task-tooltip {
    font-size: 12px;
    padding: 4px 8px;
    font-weight: 500;
}

/* Task point popup */
.task-point-popup .leaflet-popup-content {
    margin: 10px 12px;
    min-width: 180px;
}

.task-popup-content strong {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
}

.task-popup-bearing-info {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.task-popup-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Bearing edit banner */
.bearing-edit-banner {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #1e40af;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.bearing-edit-banner .bearing-value {
    font-weight: 700;
    font-size: 15px;
    min-width: 36px;
    text-align: center;
}

.bearing-edit-banner a {
    color: #93c5fd;
    text-decoration: underline;
}

/* Responsive: stack sidebar on small screens */
@media (max-width: 900px) {
    .task-planner {
        flex-direction: column;
        height: auto;
    }
    .task-sidebar {
        flex: none;
        height: auto;
        max-height: 50vh;
        min-height: 200px;
    }
    .task-map-area .map-container {
        min-height: 300px;
        height: calc(100vh - 350px);
    }
}

/* ──────────── End Task Planner ──────────── */

/* Large screens */
@media (min-width: 1400px) {
    .container {
        padding: 16px 20px;
    }
    .map-container {
        max-height: 1000px;
    }
}

/* Medium-large desktops (1080p) */
@media (max-width: 1200px) {
    .site-logo {
        height: 60px;
    }
    .header-text h1 {
        font-size: 1.3rem;
    }
    .header-text p {
        font-size: 0.8rem;
    }
    .map-sidebar {
        flex: 0 0 200px;
    }
    .task-sidebar {
        flex: 0 0 300px;
    }
    .aip-sidebar {
        flex: 0 0 340px;
    }
    .aip-layout {
        gap: 12px;
    }
}

/* Medium screens (tablets) */
@media (max-width: 1024px) {
    .container {
        padding: 10px;
    }

    .map-container {
        min-height: 350px;
    }

    .site-logo {
        height: 50px;
    }

    header h1 {
        font-size: 2rem;
    }

    .header-text p {
        display: none;
    }

    .map-view {
        gap: 8px;
    }

    .map-sidebar {
        flex: 0 0 180px;
    }

    .task-sidebar {
        flex: 0 0 280px;
    }

    .task-sidebar .wind-fields-grid {
        grid-template-columns: 1fr 1fr;
    }

    .aip-sidebar {
        flex: 0 0 300px;
    }

    .aip-field-row {
        flex-direction: column;
        gap: 0;
    }

    #main-tabs sl-tab-panel::part(base) {
        padding: 8px;
    }
}

/* Small screens (mobile) */
@media (max-width: 768px) {
    .container {
        padding: 8px;
    }

    .map-container {
        height: calc(100vh - 200px);
        min-height: 280px;
    }

    header h1 {
        font-size: 1.5rem;
    }
    
    header p {
        font-size: 0.9rem;
    }
    
}

/* Extra small screens */
@media (max-width: 480px) {
    .map-container {
        height: calc(100vh - 280px);
        min-height: 250px;
    }
    
    header h1 {
        font-size: 1.3rem;
    }
    
    .site-logo {
        height: 65px;
    }
    
}

/* ──────────── XCSoar Repository Modal ──────────── */

.xcsoar-repo-dialog {
    max-width: 640px;
}

.xcsoar-repo-body {
    padding: 16px 20px 20px;
}

.xcsoar-repo-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.xcsoar-repo-filters select {
    flex: 0 0 130px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 13px;
}

.xcsoar-repo-filters input {
    flex: 1 1 160px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 13px;
}

.xcsoar-repo-status {
    padding: 12px 0;
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
}

.xcsoar-repo-list {
    max-height: 440px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.xcsoar-repo-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.xcsoar-repo-item:last-child {
    border-bottom: none;
}

.xcsoar-repo-item:hover {
    background: var(--background);
}

.xcsoar-repo-item-info {
    display: flex;
    align-items: baseline;
    gap: 7px;
    flex: 1;
    min-width: 0;
}

.xcsoar-repo-item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.xcsoar-repo-date {
    color: var(--text-secondary);
    font-size: 11px;
    white-space: nowrap;
}

.xcsoar-badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
    flex-shrink: 0;
}

.xcsoar-badge-wp {
    background: #dbeafe;
    color: #1e40af;
}

.xcsoar-badge-as {
    background: #dcfce7;
    color: #166534;
}

/* ── Admin Panel ─────────────────────────────────────────────────────────── */

.admin-panel {
    padding: 16px;
    max-width: 1200px;
    color: var(--text-primary);
}

.admin-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.admin-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--text-primary);
}

.admin-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 14px;
}

.admin-table-wrap {
    overflow-x: auto;
    transition: opacity .2s;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .87rem;
}

.admin-table th {
    background: var(--surface);
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
    color: var(--text-secondary);
}

.admin-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-primary);
}

.admin-table td code {
    color: var(--primary-color);
    background: var(--surface);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: .82rem;
}

.admin-table tr:hover td {
    background: var(--surface);
}

.admin-cell-email {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-actions-cell {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: nowrap;
}

.admin-error {
    color: var(--danger-color);
    padding: 8px 0;
    font-size: .9rem;
}

/* Content sub-panel */
.admin-content-user-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .95rem;
    color: var(--text-primary);
}

.admin-content-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.admin-content-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-primary);
}

.admin-content-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.admin-content-item-name {
    font-weight: 600;
    font-size: .9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-content-item-meta {
    font-size: .78rem;
    color: var(--text-secondary);
}

/* Usage tracking panel */
.usage-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.usage-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    background: var(--surface);
    text-align: center;
    color: var(--text-primary);
}

.usage-card-label {
    font-size: .75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}

.usage-card-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-color);
}

.usage-card-errors {
    color: var(--danger-color);
}

.usage-daily-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 100px;
    padding: 8px 0;
}

.usage-bar {
    flex: 1;
    min-width: 4px;
    background: var(--primary-color);
    border-radius: 2px 2px 0 0;
    position: relative;
    cursor: default;
}

.usage-bar:hover {
    background: var(--primary-hover);
}

.usage-bar[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: .7rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
}


/* Confirmation dialog — handled by Shoelace <sl-dialog> */

/* Share button (teal variant) */
sl-button.share-btn::part(base) {
    background-color: #0891b2;
    border-color: #0891b2;
    color: white;
}
sl-button.share-btn::part(base):hover {
    background-color: #0e7490;
    border-color: #0e7490;
}

/* ── Theme Toggle ──────────────────────────────── */
#theme-toggle {
    font-size: 1.2rem;
}

#theme-toggle i {
    transition: transform 0.3s ease;
}

/* ── Dark Theme ────────────────────────────────── */
html.sl-theme-dark {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --success-color: #10b981;
    --success-hover: #059669;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --secondary-color: #9ca3af;
    --secondary-hover: #d1d5db;
    --background: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

/* Dark theme: native inputs */
html.sl-theme-dark input,
html.sl-theme-dark select,
html.sl-theme-dark textarea {
    background-color: var(--surface);
    color: var(--text-primary);
    border-color: var(--border);
}

/* Range inputs must stay transparent so dual-range stacking works */
html.sl-theme-dark input[type="range"].dual-range {
    background-color: transparent !important;
}

/* Dark theme: coffee banner */
html.sl-theme-dark .coffee-banner a {
    background-color: #ca8a04;
    color: #fff;
}

/* Dark theme: Leaflet map controls */
html.sl-theme-dark .leaflet-control-zoom a,
html.sl-theme-dark .leaflet-control-layers {
    background-color: var(--surface);
    color: var(--text-primary);
    border-color: var(--border);
}

/* Dark theme: map popups */
html.sl-theme-dark .leaflet-popup-content-wrapper,
html.sl-theme-dark .leaflet-popup-tip {
    background: var(--surface);
    color: var(--text-primary);
}

/* Dark theme: wind map control */
html.sl-theme-dark .wind-map-control {
    background: rgba(30, 41, 59, 0.94);
}

/* Dark theme: form backgrounds */
html.sl-theme-dark .form-group input,
html.sl-theme-dark .form-group select,
html.sl-theme-dark .form-group textarea {
    background: var(--surface);
    color: var(--text-primary);
}

/* Dark theme: waypoint table */
html.sl-theme-dark .waypoints-table th {
    background-color: var(--surface);
}

html.sl-theme-dark .waypoints-table tr:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

/* Dark theme: task point cards */
html.sl-theme-dark .task-point-card {
    background: var(--surface);
}

/* Dark theme: XCSoar repo badges */
html.sl-theme-dark .xcsoar-badge-wp {
    background: #1e3a5f;
    color: #93c5fd;
}

html.sl-theme-dark .xcsoar-badge-as {
    background: #14532d;
    color: #86efac;
}

/* ── Site Footer ───────────────────────────────── */
.site-footer {
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    padding: 14px 0;
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.site-footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.site-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
}

.site-footer a:hover {
    color: var(--primary);
}

.footer-sep {
    color: var(--border);
}
/*  Auth & Browse UI  */

.browse-results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 420px;
    overflow-y: auto;
}

.browse-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    transition: background 0.15s;
}

.browse-item:hover {
    background: var(--surface);
}

.browse-item-main {
    flex: 1;
    min-width: 0;
}

.browse-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.browse-item-meta {
    display: flex;
    gap: 12px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
    margin-top: 2px;
}

.browse-item-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.browse-item-badges {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.browse-item-minimap {
    flex-shrink: 0;
    background: #f0f4ff;
    border-radius: 4px;
    border: 1px solid #c7d2fe;
    align-self: center;
}

.browse-item-countries {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    margin-top: 3px;
}

.browse-info-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.9rem;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.browse-info-btn:hover,
.browse-info-btn.active {
    color: var(--accent, #3b82f6);
    background: rgba(59, 130, 246, 0.1);
}

.browse-item-details {
    flex: 0 0 100%;
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.browse-detail-item {
    display: inline-block;
    margin-right: 16px;
    margin-bottom: 2px;
}

.browse-detail-desc {
    display: block;
    margin-top: 4px;
    word-break: break-word;
}

.browse-points-list {
    margin: 0;
    padding-left: 20px;
    columns: 2;
    column-gap: 24px;
}

.browse-points-list li {
    break-inside: avoid;
    margin-bottom: 2px;
}

.browse-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px 0;
    font-size: 0.9rem;
}

.browse-page-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0 8px;
}

/* AI Planner panel */
.ai-planner-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 32px 16px;
}

/* When the real form is rendered, let it fill the panel */
.ai-planner-panel:has(.aip-layout) {
    align-items: stretch;
    justify-content: flex-start;
    padding: 12px 16px;
    width: 100%;
}

.ai-upgrade-cta {
    text-align: center;
    max-width: 520px;
}

.ai-upgrade-cta h2 {
    margin: 0 0 12px;
    font-size: 1.4rem;
}

.ai-upgrade-cta p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.ai-planner-content {
    text-align: left;
    max-width: none;
    width: 100%;
}

.ai-planner-content h2 {
    margin-bottom: 12px;
}

.aip-layout {
    display: flex;
    gap: 16px;
    height: calc(100vh - 200px);
    min-height: 450px;
    width: 100%;
    overflow: hidden;
}

.aip-sidebar {
    flex: 0 0 360px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
    min-width: 0;
}

.aip-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.aip-form-card {
    width: 100%;
    overflow: hidden;
}

.aip-form-card::part(body) {
    padding: 10px 12px;
    overflow: hidden;
}

.aip-form-card sl-input,
.aip-form-card sl-select,
.aip-form-card sl-radio-group {
    margin-bottom: 10px;
    max-width: 100%;
}

.aip-form-card sl-radio-group::part(button-group),
.aip-form-card sl-radio-group::part(button-group__base) {
    flex-wrap: wrap;
}

.aip-form-card sl-textarea {
    max-width: 100%;
}

.aip-field-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Airport autocomplete */
.aip-autocomplete-wrap {
    position: relative;
}

.aip-glider-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.aip-custom-badge {
    font-size: 0.68rem;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 4px;
    padding: 1px 5px;
    font-weight: 500;
    flex-shrink: 0;
}

.aip-ac-list {
    display: none;
    position: absolute;
    z-index: 100;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    margin-top: 2px;
    color: var(--text-primary);
}

.aip-ac-list.open {
    display: block;
}

.aip-ac-item {
    padding: 6px 10px;
    cursor: pointer;
    font-size: .85rem;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-primary);
}

.aip-ac-item:hover,
.aip-ac-item.active {
    background: var(--primary-color);
    color: #fff;
}

.aip-ac-item:hover .aip-ac-item-meta,
.aip-ac-item.active .aip-ac-item-meta {
    color: rgba(255,255,255,.75);
}

.aip-ac-item-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aip-ac-item-meta {
    color: var(--text-secondary);
    font-size: .75rem;
    white-space: nowrap;
}

.aip-field-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.aip-field-row > * {
    flex: 1 1 120px;
    min-width: 0;
}

.aip-constraints {
    margin-bottom: 8px;
}

.aip-constraints-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aip-class-toggles {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Status / empty state */
.aip-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
    height: 100%;
}

.aip-empty-state h3 {
    margin: 0 0 8px;
    color: var(--text-primary, #e0e0e0);
}

.aip-empty-state p {
    max-width: 400px;
    line-height: 1.5;
}

.aip-error-state {
    color: var(--danger-color);
}

/* Loading */
.aip-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    height: 100%;
    color: var(--text-secondary);
    gap: 12px;
}
.aip-loading[hidden] {
    display: none;
}

/* Result */
.aip-result-card {
    width: 100%;
}

.aip-result-summary {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.aip-stat {
    display: flex;
    gap: 8px;
    align-items: center;
}

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

.aip-stat label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
}

.aip-stat strong {
    font-size: 1rem;
}

.aip-result-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* Legs table */
.aip-legs {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
    margin-bottom: 12px;
}

.aip-legs th,
.aip-legs td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.aip-legs th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
}

/* Conflicts */
.aip-conflicts h4 {
    font-size: 0.9rem;
    margin: 12px 0 6px;
    color: #d97706;
}

.aip-conflict-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
}

.aip-conflict-list li {
    padding: 4px 0;
    display: flex;
    gap: 6px;
    align-items: center;
}

/* AI narrative */
.aip-narrative-box {
    display: flex;
    gap: 10px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.88rem;
    line-height: 1.5;
    margin-top: 12px;
    color: var(--text-primary);
}

.aip-narrative-box > i {
    color: var(--primary-color);
    margin-top: 2px;
    flex-shrink: 0;
}

.aip-narrative-box.aip-weather-summary {
    background: var(--surface);
    border-left: 3px solid var(--primary-color);
}

.aip-narrative-box.aip-safety-notes {
    border-left: 3px solid var(--sl-color-warning-500, #e6a700);
}

.aip-narrative-box.aip-safety-notes ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

.aip-ai-attr {
    text-align: right;
    color: var(--text-secondary);
    margin-top: 8px;
    font-size: 0.78rem;
}

/* Score badge */
.aip-score-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.85rem;
}
.aip-score-excellent { background: var(--sl-color-success-100, #d4edda); color: var(--sl-color-success-700, #155724); }
.aip-score-good      { background: var(--sl-color-primary-100, #cce5ff); color: var(--sl-color-primary-700, #004085); }
.aip-score-marginal  { background: var(--sl-color-warning-100, #fff3cd); color: var(--sl-color-warning-700, #856404); }
.aip-score-poor      { background: var(--sl-color-danger-100, #f8d7da);  color: var(--sl-color-danger-700, #721c24);  }

html.sl-theme-dark .aip-score-excellent { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
html.sl-theme-dark .aip-score-good      { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
html.sl-theme-dark .aip-score-marginal  { background: rgba(234, 179, 8, 0.15);  color: #fde047; }
html.sl-theme-dark .aip-score-poor      { background: rgba(239, 68, 68, 0.15);  color: #fca5a5; }

/* Terrain info */
.aip-terrain-info {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    margin-top: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.aip-terrain-info i {
    color: var(--text-secondary);
}

/* Alternative routes */
.aip-alternatives h4 {
    margin: 14px 0 8px;
    font-size: 0.92rem;
    color: var(--text-primary);
}

.aip-alt-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.aip-alt-card {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.aip-alt-desc { flex: 1; }
.aip-alt-dist { color: var(--text-secondary); }
.aip-alt-score { font-weight: 600; min-width: 50px; text-align: right; }

/* ── AI Planner: Session History Drawer ── */

.aip-history-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 2px;
}

.aip-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.aip-history-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-secondary);
}

.aip-history-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.aip-history-card:hover {
    border-color: var(--sl-color-primary-400);
    background: var(--surface-hover, var(--surface));
}

.aip-history-card.active {
    border-color: var(--sl-color-primary-500);
    background: var(--sl-color-primary-50, rgba(59, 130, 246, 0.05));
}

html.sl-theme-dark .aip-history-card.active {
    background: rgba(59, 130, 246, 0.1);
}

.aip-history-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.aip-history-card-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.aip-history-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.aip-history-card-meta i {
    margin-right: 3px;
    font-size: 0.7rem;
}

.aip-history-card-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.aip-history-card-footer small:first-child {
    flex: 1;
}

.aip-history-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity .15s, color .15s;
    padding: 2px 4px;
    font-size: 0.8rem;
}

.aip-history-card:hover .aip-history-delete {
    opacity: 1;
}

.aip-history-delete:hover {
    color: var(--sl-color-danger-500);
}

.aip-history-error {
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--sl-color-danger-500);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
    .aip-layout {
        flex-direction: column;
        height: auto;
    }
    .aip-sidebar {
        flex: none;
        width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE-FIRST RESPONSIVE OVERRIDES
   All rules below use max-width so desktop is untouched.
   ═══════════════════════════════════════════════════════════ */

/* ── 768px: tablets & large phones ── */
@media (max-width: 768px) {

    /* Container padding */
    .container {
        padding: 6px;
    }

    /* ── Header ── */
    .modern-header {
        flex-wrap: wrap;
        gap: 6px;
        padding: 6px 10px;
        margin-bottom: 6px;
    }

    .site-logo {
        height: 32px;
    }

    .header-brand {
        gap: 8px;
    }

    .header-text h1 {
        font-size: 1rem;
    }

    .header-text p {
        display: none;
    }

    /* Collapse the toolbar: hide coffee btn only */
    #lang-selector {
        width: 90px !important;
    }

    .header-support-btn {
        display: none;
    }

    .header-toolbar sl-divider[vertical] {
        display: none;
    }

    .header-toolbar {
        gap: 4px;
    }

    /* ── Status bar ── */
    .status-bar {
        padding: 4px 8px;
        margin-bottom: 6px;
        font-size: 0.8rem;
    }

    /* ── Tabs: icon-only on mobile ── */
    #main-tabs sl-tab span[data-i18n] {
        display: none;
    }

    #main-tabs sl-tab i {
        margin-right: 0;
        font-size: 1rem;
    }

    #main-tabs sl-tab-panel::part(base) {
        padding: 6px;
    }

    /* ── Map View: sidebar as collapsible horizontal bar ── */
    .map-view {
        flex-direction: column;
        height: auto;
        gap: 6px;
    }

    .map-sidebar {
        flex: none;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        overflow-y: visible;
        overflow-x: auto;
        max-height: none;
    }

    .map-sidebar > sl-card {
        flex: 1 1 auto;
        min-width: 0;
    }

    .map-sidebar .map-file-card,
    .map-sidebar .map-tools-card {
        flex: 0 1 auto;
    }

    .map-sidebar .map-file-card::part(body),
    .map-sidebar .map-tools-card::part(body) {
        padding: 4px 6px;
    }

    .map-sidebar-actions {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }

    .map-sidebar-actions sl-button {
        width: auto;
        flex: 0 0 auto;
    }

    /* Hide generate waypoints card on mobile by default (too large) */
    .map-wpgen-card {
        display: none;
    }

    /* Map takes remaining viewport */
    .map-content-area .map-container {
        min-height: 300px;
        height: calc(100vh - 240px);
    }

    /* ── Map toolbar ── */
    .map-toolbar {
        padding: 6px;
        gap: 4px;
    }

    .map-toolbar sl-button-group {
        overflow-x: auto;
        max-width: 100%;
    }

    /* ── Task planner ── */
    .task-planner {
        gap: 8px;
    }

    .task-sidebar {
        max-height: 45vh;
        min-height: 0;
    }

    .task-map-area .map-container {
        height: 50vh;
        min-height: 250px;
    }

    /* Wind grid: 2-col instead of 3 */
    .wind-fields-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* ── Browse dialog ── */
    .browse-item {
        flex-wrap: wrap;
        gap: 6px;
    }

    .browse-item-minimap {
        display: none;
    }

    .browse-item-badges {
        order: 3;
    }

    /* ── Waypoint table: hide lat/lon columns ── */
    .waypoints-table th:nth-child(5),
    .waypoints-table td:nth-child(5),
    .waypoints-table th:nth-child(6),
    .waypoints-table td:nth-child(6) {
        display: none;
    }

    /* ── Dialogs: full-width on mobile ── */
    sl-dialog::part(panel) {
        width: 98vw;
        max-width: 98vw;
    }
}

/* ── 480px: phones ── */
@media (max-width: 480px) {

    .modern-header {
        padding: 6px 8px;
    }

    .site-logo {
        height: 28px;
    }

    .header-text h1 {
        font-size: 0.9rem;
    }

    /* Single-column export actions */
    .export-actions-grid {
        grid-template-columns: 1fr;
    }

    /* Single-column wind fields */
    .wind-fields-grid {
        grid-template-columns: 1fr;
    }

    /* Task sidebar shorter so map is more visible */
    .task-sidebar {
        max-height: 35vh;
    }

    .task-map-area .map-container {
        height: 55vh;
    }

    /* Map on phones: maximize space */
    .map-content-area .map-container {
        height: calc(100vh - 200px);
        min-height: 260px;
    }

    /* Hide map sidebar file card on small phones */
    .map-sidebar .map-file-card {
        display: none;
    }

    /* Browse points list: single column */
    .browse-points-list {
        columns: 1;
    }

    /* Map toolbar buttons: icon only */
    .map-toolbar sl-button span[data-i18n] {
        display: none;
    }

    .map-toolbar sl-button i[slot="prefix"] {
        margin-right: 0;
    }
}
