:root {
    --bg-app: #e8eef4;
    --surface: rgba(255,255,255,0.96);
    --surface-strong: #ffffff;
    --surface-soft: #f4f8fb;
    --line: #d4dde6;
    --line-soft: #e4ecf2;
    --text-main: #1c2e3d;
    --text-soft: #5d7a8d;
    --text-faint: #8fa4b3;
    --accent: #4d8fc4;
    --accent-soft: #d2e6f5;
    --accent-strong: #1f6faa;
    --selected: #f0a040;
    --selected-soft: rgba(240,160,64,0.12);
    --glow: rgba(77,143,196,0.22);
    --shadow-soft: 0 4px 14px rgba(20,38,56,0.09), 0 1px 3px rgba(20,38,56,0.06);
    --shadow-strong: 0 12px 32px rgba(20,38,56,0.14), 0 2px 6px rgba(20,38,56,0.08);
    --shadow-3d: 0 4px 14px rgba(20,38,56,0.10), 0 1px 3px rgba(20,38,56,0.07);
    --top-route-left: 66px;
    --route-badge-left: 66px;
}


html, body {
    margin: 0;
    height: 100%;
    font-family: Arial, sans-serif;
    overflow: hidden;
    background: var(--bg-app);
    color: var(--text-main);
}

body {
    position: relative;
}

#map {
    position: absolute;
    inset: 0;
    z-index: 1;
    filter: saturate(1.08) brightness(1.0) contrast(1.02);
    opacity: 0;
    transition: opacity 0.9s ease;
}

body.map-ready #map {
    opacity: 1;
}

.launch-splash {
    position: absolute;
    inset: 0;
    z-index: 1600;
    background: #000000;
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    opacity: 1;
    visibility: visible;
    transition: opacity 1.2s ease, visibility 1.2s ease;
}

.launch-splash.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-image {
    width: 92%;
    height: auto;
    max-width: 520px;
    max-height: 80vh;
    object-fit: contain;
    transform: scale(1.04);
    transition: transform 1.6s ease;
}

.launch-splash.animate .splash-image {
    transform: scale(1);
}

.splash-continue-btn {
    position: relative;
    margin-top: 28px;
    padding: 14px 40px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(160deg, #1f6faa 0%, #155490 100%);
    color: #ffffff;
    font-size: 16px;
    font-weight: 800;
    font-family: inherit;
    letter-spacing: 0.3px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(20,60,100,0.28);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s ease, background 0.15s ease, box-shadow 0.15s ease;
    pointer-events: none;
}

.splash-continue-btn.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.splash-continue-btn:hover {
    background: linear-gradient(160deg, #2478b8 0%, #1a619e 100%);
    box-shadow: 0 6px 20px rgba(20,60,100,0.32);
}

.splash-continue-btn:active {
    box-shadow: 0 2px 8px rgba(20,60,100,0.24);
}

.map-info-card {
    position: absolute;
    top: 132px;
    right: 14px;
    z-index: 1250;
    width: 184px;
    max-width: calc(100vw - 40px);
    overflow: auto;
    background: linear-gradient(160deg, rgba(255,255,255,0.97) 0%, rgba(252,248,243,0.97) 100%);
    border: 2px solid var(--selected);
    border-radius: 24px;
    box-shadow:
        0 0 0 4px rgba(255,123,0,0.08),
        0 16px 36px rgba(20,38,56,0.16),
        0 3px 8px rgba(20,38,56,0.10),
        inset 0 1px 0 rgba(255,255,255,0.9);
    backdrop-filter: blur(20px);
    padding: 14px 16px 14px 14px;
    transform: translateX(0);
    opacity: 1;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.map-info-card.left {
    left: auto;
    right: 14px;
}

.map-info-card.right {
    right: 14px;
}

.map-info-card.hidden {
    opacity: 0;
    transform: translateX(24px);
    pointer-events: none;
}

.map-info-card::before {
    content: none;
}

.map-info-close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-faint);
}

.map-info-close:hover {
    color: var(--text-main);
}

#mapInfoContent {
    padding-right: 18px;
    font-size: 12px;
    line-height: 1.58;
    color: var(--text-main);
    text-align: left;
}

#mapInfoContent strong {
    display: inline-block;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 6px;
    color: #213443;
}

.fab {
    background: linear-gradient(160deg, rgba(245,249,253,0.96) 0%, rgba(232,240,247,0.94) 100%);
    border: 1px solid rgba(36,54,69,0.14);
    border-radius: 20px;
    padding: 9px 11px;
    box-shadow: var(--shadow-3d);
    cursor: pointer;
    font-weight: 700;
    color: var(--text-main);
    min-width: 48px;
    min-height: 48px;
    text-align: center;
    backdrop-filter: blur(18px);
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    background: linear-gradient(160deg, rgba(255,255,255,1) 0%, rgba(240,247,252,1) 100%);
    box-shadow: 0 6px 18px rgba(20,38,56,0.13), 0 2px 5px rgba(20,38,56,0.08);
}

.fab-icon svg {
    width: 22px;
    height: 22px;
    display: block;
}

.fab-menu-btn {
    min-width: 50px;
    min-height: 50px;
}

.top-route-side {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.top-route-actions {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    flex: 0 0 auto;
}

.top-route-actions .fab-menu-btn {
    align-self: stretch;
}

.action-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 168px;
    background: linear-gradient(160deg, rgba(252,255,255,0.97) 0%, rgba(244,249,253,0.97) 100%);
    border: 1px solid rgba(77,143,196,0.2);
    border-radius: 18px;
    box-shadow: 0 16px 36px rgba(20,38,56,0.16), 0 2px 6px rgba(20,38,56,0.08), inset 0 1px 0 rgba(255,255,255,0.9);
    backdrop-filter: blur(20px);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.action-menu.hidden {
    display: none;
}

.action-menu-item {
    border: none;
    background: transparent;
    color: var(--text-main);
    border-radius: 12px;
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
    line-height: 1.2;
    font-family: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.action-menu-item:hover {
    background: rgba(77,143,196,0.1);
    color: var(--accent-strong);
}

.warning-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 0 8px;
    margin-top: 4px;
    border-radius: 999px;
    background: #fff4e7;
    color: #b17d44;
    border: 1px solid #f0d7b4;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.waypoint-warning .waypoint-marker,
.waypoint-warning .auto-waypoint-marker {
    box-shadow: 0 0 0 4px rgba(239,179,111,0.16), 0 2px 5px rgba(0,0,0,0.08);
}

#drawer {
    position: absolute;
    left: 18px;
    right: 14px;
    bottom: 0;
    height: 38%;
    min-height: 34px;
    max-height: 88%;
    background: linear-gradient(180deg, rgba(248,252,255,0.92) 0%, rgba(240,247,253,0.94) 100%);
    border-top-left-radius: 32px;
    border-top-right-radius: 32px;
    border-top: 2px solid var(--selected);
    border-left: 2px solid var(--selected);
    border-right: 2px solid var(--selected);
    box-shadow:
        0 0 0 4px rgba(255,123,0,0.08),
        0 -10px 36px rgba(20,38,56,0.12),
        0 -2px 8px rgba(20,38,56,0.06);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.18s ease;
    backdrop-filter: blur(20px);
}

#drawerHandle {
    height: 34px;
    min-height: 34px;
    cursor: ns-resize;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: transparent;
    user-select: none;
    touch-action: none;
    flex: 0 0 34px;
}

.drawer-handle-bar {
    width: 54px;
    height: 5px;
    border-radius: 99px;
    background: linear-gradient(90deg, #8aadc4 0%, #a8c4d8 50%, #8aadc4 100%);
    display: block;
    flex: 0 0 auto;
    box-shadow: 0 1px 3px rgba(20,38,56,0.12);
}

.drawer-handle-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.7px;
    color: #6d8291;
    text-transform: uppercase;
    line-height: 1;
    flex: 0 0 auto;
}

#summaryStrip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(260px, 1.25fr);
    gap: 8px;
    padding: 10px 12px 10px 12px;
    background: transparent;
    align-items: stretch;
}

.summary-chip {
    background: linear-gradient(160deg, rgba(255,255,255,0.88) 0%, rgba(244,249,253,0.88) 100%);
    border: 1px solid rgba(77,143,196,0.14);
    border-radius: 18px;
    padding: 8px 10px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(20,38,56,0.06), inset 0 1px 0 rgba(255,255,255,0.7);
    backdrop-filter: blur(10px);
}

.summary-chip-button {
    padding: 6px;
    justify-content: center;
}

.summary-chip-label {
    font-size: 10px;
    color: var(--text-faint);
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: 0.45px;
    text-transform: uppercase;
}

.summary-chip-value {
    font-size: 13px;
    color: var(--text-main);
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.summary-action-btn {
    width: 100%;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    margin: 0;
}

.summary-chip-meta {
    background: rgba(247,250,252,0.72);
    border-color: rgba(219,228,235,0.72);
    padding: 9px 12px;
    justify-content: center;
    box-shadow: none;
}

.summary-chip-meta-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.summary-chip-meta-divider {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-faint);
}

.summary-chip-note {
    margin-top: 2px;
    font-size: 10px;
    line-height: 1.35;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.summary-chip-meta-store {
    display: none;
}

.tab-chip {
    background: rgba(255,255,255,0.72);
    border: 1px solid rgba(36,54,69,0.04);
    border-radius: 18px;
    padding: 2px;
    display: flex;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(25,42,60,0.03);
    backdrop-filter: blur(12px);
}

.summary-tab {
    flex: 1 1 0;
    border: none;
    background: transparent;
    color: var(--text-soft);
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    min-width: 0;
    padding: 8px 6px;
    font-size: 13px;
    border-radius: 14px;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.summary-tab.active {
    background: rgba(255,255,255,0.94);
    color: var(--text-main);
    box-shadow: 0 3px 10px rgba(25,42,60,0.06);
}

#drawerContent {
    flex: 1;
    overflow: auto;
    padding: 12px;
    background: linear-gradient(to bottom, rgba(242,249,255,0.6), rgba(235,245,255,0.75));
}

.drawer-panel {
    display: none;
}

.drawer-panel.active {
    display: block;
}

.settings-card {
    border: 1px solid rgba(77,143,196,0.16);
    border-radius: 24px;
    background: linear-gradient(160deg, rgba(255,255,255,0.88) 0%, rgba(242,249,255,0.88) 100%);
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 4px 14px rgba(20,38,56,0.08), 0 1px 3px rgba(20,38,56,0.05), inset 0 1px 0 rgba(255,255,255,0.8);
    backdrop-filter: blur(10px);
    overflow: visible;
}

.settings-card-title,
.route-panel-title {
    font-size: 12px;
    font-weight: 800;
    color: #6d8291;
    margin-bottom: 10px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.route-panel-shell {
    border: 1px solid rgba(219,228,235,0.9);
    border-radius: 24px;
    background: rgba(255,255,255,0.76);
    padding: 14px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
}

.route-panel-header {
    margin-bottom: 12px;
}

.route-panel-subtitle {
    font-size: 12px;
    color: var(--text-soft);
    margin-top: -2px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
    width: 100%;
}

.form-grid-route-setup {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    column-gap: 18px;
    row-gap: 12px;
}

.form-grid-defaults {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
}

.form-field {
    min-width: 0;
    width: 100%;
}

.settings-toggle-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: end;
}

.toggle-card {
    border: 1px solid var(--line-soft);
    border-radius: 18px;
    background: rgba(247,250,252,0.86);
    padding: 10px 12px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-main);
    font-weight: 700;
    margin: 0;
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #93b6d3;
}

.toggle-note {
    font-size: 12px;
    color: var(--text-soft);
    margin-top: 6px;
    line-height: 1.35;
}

.legend-strip {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
    padding: 2px 2px 4px 2px;
}

.legend-item {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    color: var(--text-soft);
    font-weight: 700;
}

.legend-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    display: inline-block;
}

.real-dot {
    background: white;
    border: 2px solid var(--text-main);
}

.legend-pill {
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #edf3f8;
    color: #6f92b0;
    border: 1px solid #d8e3ec;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 800;
}

label {
    display: block;
    font-size: 13px;
    color: #51697b;
    margin-bottom: 4px;
    font-weight: 700;
}

input[type="number"],
input[type="time"],
input[type="text"],
input[type="date"] {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    font-size: 14px;
    font-family: inherit;
    background: rgba(255,255,255,0.96);
    color: var(--text-main);
    min-height: 46px;
}

input[type="number"]:focus,
input[type="time"]:focus,
input[type="text"]:focus,
input[type="date"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(125,167,202,0.14);
    background: #fff;
}

button.ghost {
    border: 1px solid rgba(36,54,69,0.10);
    border-radius: 16px;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    background: linear-gradient(160deg, #f5f9fc 0%, #e8f0f7 100%);
    color: var(--text-main);
    box-shadow: 0 1px 4px rgba(20,38,56,0.08);
    transition: background 0.12s ease, box-shadow 0.12s ease;
}

button.ghost:hover {
    background: linear-gradient(160deg, #eef5fb 0%, #dceaf5 100%);
    box-shadow: 0 2px 8px rgba(20,38,56,0.11);
}

button.ghost:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
}

button.accent-ghost {
    background: linear-gradient(160deg, #e4f0fa 0%, #cce0f5 100%);
    color: var(--accent-strong);
    border-color: rgba(31,111,170,0.2);
    box-shadow: 0 1px 4px rgba(31,111,170,0.10);
}

button.accent-ghost:hover {
    background: linear-gradient(160deg, #d8eaf8 0%, #bdd5ee 100%);
    box-shadow: 0 2px 8px rgba(31,111,170,0.14);
}

button.compact {
    padding: 9px 12px;
    font-size: 13px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid rgba(232,238,243,0.95);
    border-radius: 20px;
    background: rgba(255,255,255,0.78);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    background: transparent;
}

.route-table {
    table-layout: auto;
}

thead th {
    position: sticky;
    top: 0;
    background: rgba(245,248,251,0.96);
    z-index: 2;
    font-size: 11px;
    color: #6b8091;
    font-weight: 800;
    letter-spacing: 0.25px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line-soft);
    padding: 9px 8px;
    white-space: nowrap;
}

thead th:first-child {
    border-top-left-radius: 18px;
}

thead th:last-child {
    border-top-right-radius: 18px;
}

tbody td {
    border-bottom: 1px solid rgba(232,238,243,0.8);
    padding: 8px 8px;
    text-align: center;
    white-space: nowrap;
    color: var(--text-main);
    background: rgba(255,255,255,0.32);
    vertical-align: middle;
}

tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

tbody tr:hover td {
    background: rgba(250,252,253,0.82);
}

tbody tr:last-child td:first-child {
    border-bottom-left-radius: 18px;
}

tbody tr:last-child td:last-child {
    border-bottom-right-radius: 18px;
}

.small-note {
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-soft);
    margin-top: 8px;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 78px;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.5);
}

.status-reaching {
    background: linear-gradient(160deg, #e0f0fb 0%, #c8e2f5 100%);
    color: #1a5f90;
    border: 1px solid rgba(26,95,144,0.18);
}

.status-tacking {
    background: linear-gradient(160deg, #fff3e0 0%, #ffe0b2 100%);
    color: #b85c00;
    border: 1px solid rgba(184,92,0,0.18);
}

.status-running {
    background: linear-gradient(160deg, #e4f5e8 0%, #c8ebd0 100%);
    color: #1a7a36;
    border: 1px solid rgba(26,122,54,0.18);
}

.wind-popup {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-main);
}

.wind-popup-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.wind-popup-action-btn {
    border: 1px solid rgba(36,54,69,0.12);
    border-radius: 12px;
    background: linear-gradient(160deg, #f4f9fc 0%, #e6f0f8 100%);
    color: var(--text-main);
    font-size: 12px;
    font-weight: 700;
    min-height: 34px;
    padding: 0 12px;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 1px 4px rgba(20,38,56,0.09);
    transition: background 0.12s ease, box-shadow 0.12s ease;
}

.wind-popup-action-btn:hover {
    background: linear-gradient(160deg, #e8f2fa 0%, #d8e9f5 100%);
    box-shadow: 0 2px 8px rgba(20,38,56,0.11);
}

.wind-popup-action-btn.primary {
    background: linear-gradient(160deg, #5f96c8 0%, #377eb8 100%);
    color: #ffffff;
    border-color: rgba(31,111,170,0.30);
    font-weight: 800;
    box-shadow: 0 1px 4px rgba(20,56,100,0.16);
}

.wind-popup-action-btn.primary:hover {
    background: linear-gradient(160deg, #6fa3d0 0%, #4489c0 100%);
    box-shadow: 0 2px 8px rgba(20,56,100,0.20);
}

.wind-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f0f4f8;
    color: #1a5fa8;
    border: 1.5px solid #1a5fa8;
    font-size: 11px;
    font-weight: 600;
    font-family: system-ui, sans-serif;
    padding: 4px 8px 4px 6px;
    border-radius: 12px;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    cursor: pointer;
    user-select: none;
}

.leg-arrow {
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 14px solid #1a65a8;
    filter: drop-shadow(0 2px 3px rgba(20,38,56,0.28));
}

.waypoint-marker {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(160deg, #ffffff 0%, #f0f5fa 100%);
    color: #1c2e3d;
    border: 2.5px solid #1c3a52;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 900;
    box-shadow:
        0 4px 10px rgba(20,38,56,0.22),
        0 1px 3px rgba(20,38,56,0.14),
        inset 0 1px 0 rgba(255,255,255,0.9);
}

.waypoint-marker.selected {
    background: linear-gradient(160deg, #fff8ed 0%, #ffe8c0 100%);
    color: #a05c00;
    border-color: #d08020;
    box-shadow:
        0 0 0 4px rgba(240,160,64,0.2),
        0 4px 10px rgba(184,100,0,0.22),
        inset 0 1px 0 rgba(255,255,255,0.8);
}

.waypoint-marker.linked {
    box-shadow:
        0 0 0 4px rgba(77,143,196,0.25),
        0 4px 10px rgba(20,38,56,0.18),
        inset 0 1px 0 rgba(255,255,255,0.9);
}

.auto-waypoint-marker {
    min-width: 24px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: linear-gradient(160deg, #f0f6fc 0%, #ddeaf5 100%);
    color: #2d6a9f;
    border: 1.5px solid #b0cce4;
    box-shadow: 0 2px 6px rgba(20,38,56,0.12), inset 0 1px 0 rgba(255,255,255,0.8);
    opacity: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 8px;
    line-height: 1;
    white-space: nowrap;
}

.auto-waypoint-marker.selected {
    background: linear-gradient(160deg, #fff8ed 0%, #ffe8c0 100%);
    color: #a05c00;
    border-color: #d08020;
    box-shadow: 0 0 0 2px rgba(240,160,64,0.2), 0 2px 6px rgba(184,100,0,0.18);
}

.leaflet-div-icon {
    background: transparent;
    border: none;
}

#drawer.collapsed {
    height: 34px !important;
    min-height: 34px !important;
}

#drawer.collapsed #summaryStrip,
#drawer.collapsed #drawerContent {
    display: none !important;
}

@media (max-width: 1200px) {
    .form-grid-route-setup {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid-defaults {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .splash-image {
        width: 88%;
        max-width: 420px;
        max-height: 72vh;
    }

    .map-info-card {
        top: 126px;
        right: 16px;
        width: 176px;
        max-width: calc(100vw - 32px);
        max-height: 280px;
    }

    .map-info-card.left {
        left: auto;
        right: 16px;
    }

    .map-info-card.right {
        right: 16px;
    }

    #drawer {
        left: 10px;
        right: 14px;
    }

    #summaryStrip {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        padding: 8px;
    }

    .summary-chip-edit {
        grid-area: auto;
    }

    .summary-chip-delete {
        grid-area: auto;
    }

    .summary-chip-meta {
        display: none;
    }

    .summary-chip {
        padding: 6px;
    }

    .summary-chip-value {
        font-size: 10px;
    }

    .summary-tab {
        padding: 6px 2px;
        font-size: 10px;
    }

    .summary-action-btn {
        min-height: 34px;
        font-size: 11px;
        padding: 8px 6px;
        white-space: normal;
        line-height: 1.2;
        text-align: center;
    }

    .fab {
        min-width: 46px;
        min-height: 46px;
        border-radius: 18px;
    }

    .fab-icon svg {
        width: 20px;
        height: 20px;
    }

    table {
        font-size: 12px;
    }

    thead th {
        font-size: 10px;
        padding: 9px 6px;
    }

    tbody td {
        padding: 9px 6px;
    }

    .auto-waypoint-marker {
        min-width: 20px;
        height: 16px;
        padding: 0 4px;
        font-size: 7px;
    }

    .form-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .form-grid-route-setup,
    .form-grid-defaults {
        grid-template-columns: 1fr 1fr;
    }

    .form-field {
        min-width: 0;
    }

    input[type="number"],
    input[type="time"],
    input[type="text"],
    input[type="date"] {
        min-width: 0;
        max-width: 100%;
        font-size: 16px;
    }
}

/* Left settings drawer */
.settings-backdrop {
    position: absolute;
    inset: 0;
    z-index: 1290;
    background: rgba(18, 32, 44, 0.18);
    backdrop-filter: blur(2px);
    opacity: 1;
    transition: opacity 0.22s ease;
}

.settings-drawer {
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: absolute;
    top: 10px;
    left: 0;
    bottom: 44px;
    width: min(420px, calc(100vw - 32px));
    z-index: 1300;
    background: rgba(255,255,255,0.92);
    border-top: 2px solid var(--selected);
    border-right: 2px solid var(--selected);
    border-bottom: 2px solid var(--selected);
    border-left: none;
    border-top-right-radius: 28px;
    border-bottom-right-radius: 28px;
    box-shadow:
        0 0 0 4px rgba(255,123,0,0.08),
        18px 0 40px rgba(25,42,60,0.12);
    backdrop-filter: blur(20px);
    transform: translateX(0);
    transition: transform 0.24s ease, opacity 0.24s ease;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.settings-drawer::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.settings-drawer.hidden {
    transform: translateX(-100%);
    opacity: 1;
    pointer-events: auto;
}

.settings-drawer-handle {
    position: absolute;
    top: 96px;
    right: -40px;
    width: 40px;
    height: 132px;
    border: 1px solid rgba(36,54,69,0.08);
    border-left: none;
    border-top-right-radius: 20px;
    border-bottom-right-radius: 20px;
    background: rgba(255,255,255,0.94);
    box-shadow: 12px 0 24px rgba(25,42,60,0.10);
    backdrop-filter: blur(18px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-main);
    padding: 0;
    overflow: hidden;
}

.settings-drawer-handle-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 100%;
}

.settings-drawer-handle-bar {
    width: 22px;
    height: 4px;
    border-radius: 99px;
    background: #b8c5cf;
    display: block;
    flex: 0 0 auto;
}

.settings-drawer-handle-label {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #6d8291;
    text-transform: uppercase;
    line-height: 1;
    flex: 0 0 auto;
    white-space: nowrap;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
}

.settings-drawer:not(.hidden) .settings-drawer-handle-label {
    color: var(--text-main);
}

.settings-backdrop.hidden {
    opacity: 0;
    pointer-events: none;
}

.settings-drawer-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    border-top-right-radius: 26px;
    border-bottom-right-radius: 26px;
    overflow: hidden;
}

.settings-drawer-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 18px 54px 12px 24px;
    border-bottom: 1px solid rgba(219,228,235,0.8);
    background: linear-gradient(to bottom, rgba(255,255,255,0.94), rgba(250,252,253,0.82));
}

.settings-drawer-title {
    width: 100%;
    text-align: center;
    font-size: 13px;
    font-weight: 800;
    color: #6d8291;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.settings-drawer-close {
    position: absolute;
    top: 12px;
    right: 16px;
    border: none;
    background: rgba(238,243,247,0.92);
    color: var(--text-main);
    width: 38px;
    height: 38px;
    border-radius: 14px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.settings-drawer-content {
    flex: 1;
    overflow: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 12px 12px 12px 18px;
    background: linear-gradient(to bottom, rgba(250,252,253,0.74), rgba(255,255,255,0.88));
}

.settings-drawer-content::-webkit-scrollbar {
    width: 0;
    height: 0;
}

#settingsPanel {
    display: block;
}

#settingsPanel .settings-card:first-child {
    margin-top: 0;
}

#summaryStrip {
    grid-template-columns: 1.15fr 1.15fr 0.8fr 0.8fr;
}

.route-panel-only {
    display: block;
}

@media (max-width: 860px) {
    .settings-drawer {
        scrollbar-width: none;
        -ms-overflow-style: none;
        top: 8px;
        bottom: 8px;
        width: min(380px, calc(100vw - 18px));
    }

    .settings-drawer.hidden {
        transform: translateX(-100%);
    }

    .settings-drawer-handle {
        top: 92px;
        right: -38px;
        width: 38px;
        height: 122px;
    }

    .settings-drawer-handle-inner {
        gap: 7px;
    }

    .settings-drawer-handle-bar {
        width: 18px;
        height: 4px;
    }

    .settings-drawer-handle-label {
        font-size: 8px;
        letter-spacing: 0.9px;
    }
}


.form-grid-route-setup .form-field {
    min-width: 0;
}

.form-grid-route-setup .form-field-boat-speed {
    grid-column: 1;
    grid-row: 1;
}

.form-grid-route-setup .form-field-leeway {
    grid-column: 2;
    grid-row: 1;
}

.form-grid-route-setup .form-field-start-location {
    grid-column: 1;
    grid-row: 2;
}

.form-grid-route-setup .form-field-destination {
    grid-column: 2;
    grid-row: 2;
}

.form-grid-route-setup .form-field-departure-date {
    grid-column: 1 / -1;
    grid-row: 3;
}

.form-grid-route-setup .form-field-departure-time {
    grid-column: 1 / -1;
    grid-row: 4;
}

.form-grid-route-setup .form-field-live-tide {
    grid-column: 1 / -1;
    grid-row: 5;
}


@media (max-width: 700px) {
    input[type="date"],
    input[type="time"] {
        -webkit-appearance: none;
        appearance: none;
    }

    .form-grid-route-setup {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 10px;
        row-gap: 10px;
    }

    .form-grid-route-setup .form-field-boat-speed {
        grid-column: 1;
        grid-row: 1;
    }

    .form-grid-route-setup .form-field-leeway {
        grid-column: 2;
        grid-row: 1;
    }

    .form-grid-route-setup .form-field-start-location {
        grid-column: 1;
        grid-row: 2;
    }

    .form-grid-route-setup .form-field-destination {
        grid-column: 2;
        grid-row: 2;
    }

    .form-grid-route-setup .form-field-departure-date {
        grid-column: 1 / -1;
        grid-row: 3;
    }

    .form-grid-route-setup .form-field-departure-time {
        grid-column: 1 / -1;
        grid-row: 4;
    }

    .form-grid-route-setup .form-field-live-tide {
        grid-column: 1 / -1;
        grid-row: 5;
    }
}


.settings-inline-btn {
    width: 100%;
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.field-note {
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-soft);
}

.live-tide-key-card.hidden {
    display: none;
}

.live-tide-key-grid {
    grid-template-columns: 1fr;
    margin-top: 12px;
}

.live-tide-key-field input {
    width: 100%;
}

.live-tide-key-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

@media (max-width: 860px) {
    .live-tide-key-actions {
        flex-direction: column;
    }

    .live-tide-key-actions .ghost {
        width: 100%;
    }
}


.toast-message {
    position: absolute;
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%);
    z-index: 1500;
    min-width: 180px;
    max-width: min(320px, calc(100vw - 32px));
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(36,54,69,0.94);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 12px 28px rgba(25,42,60,0.18);
    backdrop-filter: blur(10px);
}

.toast-message.hidden {
    display: none;
}


.settings-drawer-content {
    min-height: 0;
}


.saved-routes-backdrop {
    position: absolute;
    inset: 0;
    z-index: 1380;
    background: rgba(18, 32, 44, 0.22);
    backdrop-filter: blur(2px);
    transition: opacity 0.18s ease;
}

.saved-routes-backdrop.hidden {
    opacity: 0;
    pointer-events: none;
}

.saved-routes-modal {
    position: absolute;
    top: 78px;
    right: 14px;
    width: min(320px, calc(100vw - 28px));
    max-height: min(62vh, 520px);
    z-index: 1390;
    background: rgba(255,255,255,0.96);
    border: 1px solid rgba(36,54,69,0.08);
    border-radius: 22px;
    box-shadow: var(--shadow-strong);
    backdrop-filter: blur(20px);
    overflow: hidden;
}

.saved-routes-modal.hidden {
    display: none;
}

.saved-routes-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 14px 48px 10px;
    border-bottom: 1px solid rgba(219,228,235,0.8);
    background: linear-gradient(to bottom, rgba(255,255,255,0.94), rgba(250,252,253,0.82));
}

.saved-routes-title {
    font-size: 12px;
    font-weight: 800;
    color: #6d8291;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.saved-routes-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 12px;
    background: rgba(238,243,247,0.92);
    color: var(--text-main);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.saved-routes-list {
    padding: 10px;
    overflow: auto;
    max-height: calc(min(62vh, 520px) - 56px);
}

.saved-route-item {
    border: 1px solid rgba(219,228,235,0.9);
    border-radius: 16px;
    background: rgba(255,255,255,0.84);
    padding: 10px 12px;
    box-shadow: var(--shadow-soft);
}

.saved-route-item + .saved-route-item {
    margin-top: 8px;
}

.saved-route-name {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 4px;
}

.saved-route-meta {
    font-size: 11px;
    color: var(--text-soft);
    line-height: 1.4;
}

.saved-route-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.saved-route-btn {
    flex: 1 1 0;
    border: none;
    border-radius: 12px;
    background: rgba(238,243,247,0.92);
    color: var(--text-main);
    font-size: 12px;
    font-weight: 700;
    min-height: 34px;
    cursor: pointer;
}

.saved-route-btn.primary {
    background: rgba(237,244,249,0.96);
    color: var(--accent-strong);
}

.saved-route-empty {
    font-size: 12px;
    color: var(--text-soft);
    text-align: center;
    padding: 18px 10px;
}


/* ===== Version Next layout pass ===== */

.top-route-bar {
    position: absolute;
    top: 14px;
    left: var(--top-route-left);
    right: 14px;
    z-index: 1185;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: stretch;
    padding: 10px 12px;
    border-radius: 22px;
    background: linear-gradient(160deg, rgba(255,255,255,0.97) 0%, rgba(245,250,255,0.97) 100%);
    border: 2px solid var(--selected);
    box-shadow:
        0 0 0 4px rgba(255,123,0,0.08),
        0 12px 28px rgba(20,38,56,0.12),
        0 2px 6px rgba(20,38,56,0.08),
        inset 0 1px 0 rgba(255,255,255,0.9);
    backdrop-filter: blur(16px);
}

.top-route-main {
    min-width: 0;
}

.top-route-kicker {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.9px;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 4px;
}

.top-route-title {
    font-size: 17px;
    font-weight: 800;
    color: #173247;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-route-inline-stats {
    display: none;
    margin-top: 5px;
    font-size: 12px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.25;
}

.top-route-subtitle {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-soft);
    min-height: 16px;
}

.top-route-stats {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.top-route-stat {
    min-width: 76px;
    padding: 7px 9px;
    border-radius: 16px;
    background: linear-gradient(160deg, #eef5fb 0%, #ddeaf6 100%);
    border: 1px solid rgba(77,143,196,0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(20,38,56,0.07), inset 0 1px 0 rgba(255,255,255,0.8);
}

.top-route-stat-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.55px;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 3px;
}

.top-route-stat-value {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-main);
    white-space: nowrap;
}

.route-mode-badge,
.route-mode-badge.hidden {
    display: none;
}

.route-mode-badge-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.45px;
    text-transform: uppercase;
}

.route-mode-badge-text {
    font-size: 11px;
    line-height: 1.35;
    color: rgba(255,255,255,0.82);
    margin-top: 2px;
}


.leg-rail-section {
    margin-bottom: 12px;
    padding: 0 2px;
}

.leg-rail-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin: 0 6px 10px;
}

.leg-rail-title {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #6d8291;
}

.leg-rail-subtitle {
    font-size: 12px;
    color: var(--text-soft);
}

.leg-rail-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 6px 8px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.leg-rail-track::-webkit-scrollbar {
    height: 7px;
}

.leg-rail-track::-webkit-scrollbar-thumb {
    background: rgba(125,167,202,0.35);
    border-radius: 999px;
}

.leg-rail-card {
    flex: 0 0 140px;
    min-height: 98px;
    border: 1px solid rgba(77,143,196,0.18);
    border-radius: 20px;
    background: linear-gradient(160deg, rgba(255,255,255,0.94) 0%, rgba(242,249,255,0.94) 100%);
    box-shadow: 0 4px 12px rgba(20,38,56,0.09), 0 1px 3px rgba(20,38,56,0.06), inset 0 1px 0 rgba(255,255,255,0.9);
    padding: 12px 12px 10px;
    scroll-snap-align: start;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.leg-rail-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(20,38,56,0.13), 0 2px 5px rgba(20,38,56,0.08), inset 0 1px 0 rgba(255,255,255,0.95);
    border-color: rgba(77,143,196,0.35);
}

.leg-rail-card.selected {
    border-color: rgba(208,128,32,0.7);
    background: linear-gradient(160deg, #fff9f0 0%, #fff0d0 100%);
    box-shadow:
        0 0 0 3px rgba(240,160,64,0.16),
        0 6px 18px rgba(168,100,0,0.14),
        0 1px 3px rgba(168,100,0,0.1),
        inset 0 1px 0 rgba(255,255,255,0.85);
}

.leg-rail-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.leg-rail-card-label {
    font-size: 20px;
    line-height: 1;
    font-weight: 800;
    color: var(--text-main);
}

.leg-rail-card-distance {
    font-size: 10px;
    color: var(--text-soft);
    font-weight: 800;
    letter-spacing: 0.4px;
}

.leg-rail-card-cts {
    font-size: 12px;
    color: var(--text-main);
    font-weight: 800;
    margin-bottom: 7px;
}

.leg-rail-card-status .status-chip {
    min-width: 0;
    padding: 0 10px;
}

.leg-rail-empty {
    min-width: 100%;
    border: 1px dashed rgba(125,167,202,0.35);
    border-radius: 22px;
    padding: 14px 16px;
    font-size: 13px;
    color: var(--text-soft);
    background: rgba(255,255,255,0.55);
}


.map-info-card.editing #mapInfoContent {
    padding-right: 16px;
}

.map-info-card.editing {
    width: 320px;
    max-width: calc(100vw - 32px);
}

.wind-popup-editor {
    min-width: 0;
}

.popup-editor-header {
    margin-bottom: 10px;
}

.popup-editor-subtitle {
    margin-top: 4px;
    color: var(--text-soft);
    font-size: 11px;
    line-height: 1.35;
    font-weight: 700;
}

.popup-editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.popup-editor-group {
    border: 1px solid rgba(219,228,235,0.95);
    border-radius: 16px;
    background: rgba(248,251,253,0.96);
    padding: 10px;
}

.popup-editor-group-title {
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.55px;
    text-transform: uppercase;
    color: var(--text-soft);
    margin-bottom: 8px;
}

.popup-editor-field {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-soft);
    font-weight: 800;
    margin-top: 7px;
}

.popup-editor-field input {
    width: 100%;
    min-height: 36px;
    box-sizing: border-box;
    border: 1px solid rgba(206,218,228,0.95);
    border-radius: 12px;
    padding: 7px 9px;
    font-size: 16px;
    font-weight: 800;
    color: var(--text-main);
    background: rgba(255,255,255,0.98);
}

.popup-editor-actions {
    margin-top: 12px;
}

@media (max-width: 767px) {
    .map-info-card.editing {
        right: 16px;
        width: calc(100vw - 32px);
        max-width: calc(100vw - 32px);
        max-height: min(72vh, 560px);
    }

    .popup-editor-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .popup-editor-group {
        padding: 9px 10px;
    }

    .popup-editor-field {
        grid-template-columns: 54px minmax(0, 1fr);
    }
}


/* v31: route legs table removed from bottom drawer */
.route-panel-shell {
    display: none !important;
}


/* v38 safe cleanup + visual polish */
:root {
    --selected: #ff7b00;
    --selected-soft: rgba(255, 123, 0, 0.12);
    --selected-line: rgba(255, 123, 0, 0.52);
    --accent-glow: rgba(77, 133, 184, 0.14);
}

/* Keep the drawer focused on actions + route legs. Header already carries route totals. */
#routePreviewCard {
    display: none !important;
}

.top-route-bar {
    box-shadow: 0 12px 26px rgba(25,42,60,0.11), 0 0 0 1px rgba(255,255,255,0.55) inset;
}

.top-route-kicker,
.leg-rail-title,
.route-panel-title,
.settings-card-title {
    color: #607d92;
}

.top-route-stat {
    border-color: rgba(125, 167, 202, 0.30);
    background: linear-gradient(180deg, rgba(248,251,253,0.98), rgba(239,246,251,0.95));
}

.top-route-stat-label {
    color: #8da0ae;
}

.summary-chip-edit .summary-action-btn {
    background: linear-gradient(135deg, #5f96c8, #377eb8);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(49,119,173,0.18);
}

body.route-editing .summary-chip-edit .summary-action-btn {
    background: linear-gradient(135deg, #ff9639, #ff7b00);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(255,123,0,0.18);
}

.summary-chip-delete .summary-action-btn:not(:disabled) {
    color: #243645;
    background: rgba(237,244,249,0.96);
}

.leg-rail-card {
    border-color: rgba(203, 219, 231, 0.96);
    background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,251,253,0.94));
}

.leg-rail-card.selected {
    border-color: var(--selected-line);
    background: linear-gradient(180deg, rgba(255,250,244,0.98), rgba(255,244,232,0.96));
    box-shadow: 0 10px 22px rgba(255,123,0,0.10), 0 0 0 1px rgba(255,123,0,0.08) inset;
}

.leg-rail-card.selected .leg-rail-card-label,
.leg-rail-card.selected .leg-rail-card-cts {
    color: #173247;
}

.status-reaching {
    background: #e9f4fb;
    color: #47789d;
}

.status-tacking {
    background: #fff0dd;
    color: #b56312;
}

.status-running {
    background: #e9f7ee;
    color: #3f7d4f;
}

.map-info-card.editing {
    border-color: var(--selected) !important;
    box-shadow: 0 16px 34px rgba(25,42,60,0.14), 0 0 0 4px rgba(255,123,0,0.08) !important;
}


.popup-editor-group {
    border-color: rgba(203, 219, 231, 0.95);
}

.popup-editor-group:first-of-type {
    border-color: rgba(77, 133, 184, 0.26);
}

.popup-editor-group:nth-of-type(2) {
    border-color: rgba(255, 123, 0, 0.26);
}

.settings-drawer.hidden {
    transform: translateX(-100%) !important;
}

.settings-drawer.hidden .settings-drawer-header,
.settings-drawer.hidden .settings-drawer-content {
    opacity: 0;
    pointer-events: none;
}

.settings-drawer.hidden .settings-drawer-handle {
    box-shadow: 10px 0 22px rgba(25,42,60,0.08);
}

@media (max-width: 767px) {
    .top-route-bar {
        border-radius: 18px;
        padding: 8px 10px;
    }

    .top-route-kicker {
        display: none;
    }

    .top-route-subtitle {
        display: none;
    }

    .top-route-title {
        font-size: 13px;
        white-space: normal;
        line-height: 1.25;
    }

    .top-route-stat {
        min-width: 60px;
        padding: 5px 7px;
    }

    .top-route-stat-value {
        font-size: 11px;
    }

    .leg-rail-card.selected {
        box-shadow: 0 8px 18px rgba(255,123,0,0.12);
    }

    .summary-chip-meta {
        display: none;
    }

    #summaryStrip {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        padding: 8px;
    }

    .summary-action-btn {
        min-height: 36px;
        font-size: 11px;
        padding: 6px 6px;
        white-space: normal;
        line-height: 1.2;
        text-align: center;
    }

    .route-mode-badge,
    .route-mode-badge.hidden {
        display: none;
    }

    /* Info popup: right half of screen only */
    .map-info-card {
        left: auto !important;
        right: 14px !important;
        width: calc(50vw - 20px) !important;
        max-width: none !important;
    }

    /* Edit conditions popup: full width, above settings drawer */
    .map-info-card.editing {
        left: 14px !important;
        right: 14px !important;
        width: auto !important;
        z-index: 1350 !important;
    }
}


/* ============================================================
   TRIAL / SUBSCRIPTION SCREENS
   ============================================================ */

.trial-overlay {
    position: absolute;
    inset: 0;
    z-index: 1700;
    background: #edf2f6;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    overflow-y: auto;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.trial-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.trial-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 32px 24px 28px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 12px 32px rgba(20,38,56,0.14), 0 2px 6px rgba(20,38,56,0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.trial-logo {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    object-fit: contain;
    margin-bottom: 14px;
}

.trial-app-name {
    font-family: Arial, sans-serif;
    font-size: 22px;
    font-weight: 800;
    color: #173247;
    text-align: center;
    letter-spacing: -0.3px;
    line-height: 1.15;
}

.trial-app-sub {
    font-family: Arial, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #4d8fc4;
    text-align: center;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.trial-tagline {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: #5d7a8d;
    text-align: center;
    margin-bottom: 20px;
}

.trial-paywall-sub {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: #5d7a8d;
    text-align: center;
    margin-bottom: 20px;
}

.trial-feature-list {
    list-style: none;
    padding: 0;
    margin: 0 0 22px 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.trial-feature-list li {
    font-family: Arial, sans-serif;
    font-size: 13.5px;
    color: #1c2e3d;
    padding-left: 22px;
    position: relative;
    line-height: 1.4;
}

.trial-feature-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4d8fc4;
}

.trial-btn-primary {
    width: 100%;
    padding: 15px 20px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(160deg, #1f6faa 0%, #155490 100%);
    color: #ffffff;
    font-family: Arial, sans-serif;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.2px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(20,60,100,0.28);
    margin-bottom: 12px;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.trial-btn-primary:active {
    opacity: 0.88;
    transform: scale(0.98);
}

.trial-terms {
    font-family: Arial, sans-serif;
    font-size: 11px;
    color: #8fa4b3;
    text-align: center;
    line-height: 1.6;
    margin-bottom: 10px;
}

.trial-btn-link {
    background: none;
    border: none;
    color: #4d8fc4;
    font-family: Arial, sans-serif;
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    padding: 4px 0;
}

.trial-plans {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.trial-plan-card {
    border: 1.5px solid #d4dde6;
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    position: relative;
    background: #f4f8fb;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.trial-plan-card.trial-plan-selected {
    border-color: #4d8fc4;
    background: #e8f2fb;
}

.trial-plan-badge {
    position: absolute;
    top: -10px;
    left: 14px;
    background: #ff7b00;
    color: #ffffff;
    font-family: Arial, sans-serif;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 6px;
}

.trial-plan-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.trial-plan-name {
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #1c2e3d;
}

.trial-plan-note {
    font-family: Arial, sans-serif;
    font-size: 11px;
    color: #8fa4b3;
    margin-top: 2px;
}

.trial-plan-price {
    font-family: Arial, sans-serif;
    font-size: 20px;
    font-weight: 800;
    color: #1f6faa;
}

.trial-plan-price span {
    font-size: 12px;
    font-weight: 400;
    color: #8fa4b3;
}

/* ── Privacy policy links ── */

.trial-policy-link {
    margin-top: 8px;
    text-align: center;
}

.trial-policy-link a {
    font-family: Arial, sans-serif;
    font-size: 11px;
    color: #8fa4b3;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.trial-policy-link a:hover {
    color: #4d8fc4;
}

.settings-policy-row {
    padding: 16px 4px 8px;
    border-top: 1px solid var(--border-soft, #e8eef4);
    margin-top: 8px;
    text-align: center;
}

.settings-policy-link {
    font-size: 12px;
    color: var(--text-muted, #8fa4b3);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.settings-policy-link:hover {
    color: var(--accent, #4d8fc4);
}

/* ── Waypoint coordinates in leg cards ── */
.leg-rail-card-coord {
    font-size: 10px;
    color: var(--text-muted, #8fa4b3);
    font-family: monospace;
    letter-spacing: 0.3px;
    margin-bottom: 5px;
}

.selected-leg-card-coords {
    font-size: 11px;
    color: var(--text-muted, #8fa4b3);
    font-family: monospace;
    margin-top: 4px;
    letter-spacing: 0.3px;
}
