/* CSS Variables for theming */
:root {
    --bg-primary: #0a1628;
    --bg-secondary: #152238;
    --bg-card: #1a2d4a;
    --text-primary: #e8f0ff;
    --text-secondary: #8fa4c4;
    --accent-blue: #4a9eff;
    --accent-gold: #ffd700;
    --walk-window: rgba(144, 238, 144, 0.25);
    --walk-window-border: rgba(144, 238, 144, 0.5);
    --high-tide: #ff6b6b;
    --low-tide: #4ecdc4;
    --current-marker: #ffd700;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    background-color: var(--bg-primary);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

body.embed-mode {
    background: var(--bg-card);
    min-height: auto;
}

/* Links */
a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:visited {
    color: #7eb8ff;
}

a:hover {
    color: #7dc4ff;
    text-decoration: underline;
}

a:active {
    color: #9dd0ff;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.embed-mode .container {
    max-width: none;
    min-height: auto;
    padding: 0;
}

/* Header */
header {
    text-align: center;
    padding: 1.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1.5rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    color: var(--text-primary);
}

header .location {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.selected-datetime {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.35rem;
}

.selected-datetime strong {
    color: var(--accent-gold);
    font-weight: 700;
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.embed-mode main {
    gap: 0;
}

/* Section Styling */
section {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.embed-mode section {
    border-radius: 0;
    box-shadow: none;
    padding: 1rem;
}

section h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.embed-mode header,
.embed-mode footer,
.embed-mode .help-section,
.embed-mode .walk-section,
.embed-mode .no-station-message,
.embed-mode .search-modal-overlay,
.embed-mode .date-popover-overlay,
.embed-tidechart .moon-section,
.embed-moonphase .tide-section,
.omit-tiderange .tide-regime {
    display: none;
}

/* Moon Section */
.moon-display {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.moon-visual {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
}

#moonCanvas {
    width: 100%;
    height: 100%;
}

/* Moon rise/set times */
.moon-times {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.moon-time-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.moon-time-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.moon-time-value {
    font-size: 0.95rem;
    color: var(--accent-gold);
    font-weight: 500;
}

/* Perigee/apogee row and the next-supermoon line (kept separate from the times row) */
.moon-apsides {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin-top: 0.6rem;
}

.moon-supermoon {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-top: 0.6rem;
}

.moon-supermoon:empty {
    display: none;
}

.moon-info {
    flex: 1;
}

.phase-name {
    font-size: 1.4rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.illumination {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.next-event {
    color: var(--accent-gold);
    font-size: 0.95rem;
}

/* Tide Section */
.station-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}

.tide-chart-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    height: 200px;
    position: relative;
}

#tideChart {
    width: 100%;
    height: 100%;
}

.tide-times {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.embed-tidechart .tide-times .tide-day:nth-child(2) {
    display: none;
}

.tide-day h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tide-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tide-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    font-size: 0.9rem;
}

.tide-item.high {
    border-left: 3px solid var(--high-tide);
}

.tide-item.low {
    border-left: 3px solid var(--low-tide);
}

.tide-type {
    font-weight: 500;
    min-width: 35px;
}

.tide-item.high .tide-type {
    color: var(--high-tide);
}

.tide-item.low .tide-type {
    color: var(--low-tide);
}

.tide-time {
    color: var(--text-primary);
}

.tide-height {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-left: auto;
}

/* Tidal regime badge + upcoming spring/neap/king dates */
.tide-regime {
    margin-bottom: 1rem;
}

.tide-regime-badge {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.tide-regime-badge.spring {
    color: var(--accent-gold);
    border-color: rgba(255, 215, 0, 0.4);
}

.tide-regime-badge.neap {
    color: var(--low-tide);
    border-color: rgba(78, 205, 196, 0.4);
}

.tide-regime-badge.king {
    color: var(--high-tide);
    border-color: rgba(255, 107, 107, 0.5);
    background: rgba(255, 107, 107, 0.12);
}

.tide-regime-badge.mid {
    color: var(--text-secondary);
}

.tide-regime-upcoming {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.6rem;
}

/* Walk Section */
.walk-info {
    background: rgba(144, 238, 144, 0.1);
    border: 1px solid var(--walk-window-border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.walk-window {
    text-align: center;
}

.walk-window .time-range {
    font-size: 1.5rem;
    font-weight: 500;
    color: #90ee90;
    margin-bottom: 0.25rem;
}

.walk-window .description {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.walk-window .low-tide-info {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--low-tide);
}

.no-walk {
    text-align: center;
    color: var(--text-secondary);
}

.calendar-link {
    text-align: center;
}

.calendar-link a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-blue);
    text-decoration: none;
    padding: 0.75rem 1.25rem;
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.calendar-link a:hover {
    background: rgba(74, 158, 255, 0.2);
    border-color: rgba(74, 158, 255, 0.5);
}

.calendar-icon {
    font-size: 1.2rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.last-updated {
    margin-top: 0.5rem;
    font-size: 0.75rem;
}

/* Responsive Adjustments */
@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }

    header h1 {
        font-size: 1.6rem;
    }

    section {
        padding: 1.25rem;
        border-radius: 12px;
    }

    .moon-display {
        flex-direction: column;
        text-align: center;
    }

    .moon-visual {
        width: 120px;
        height: 120px;
    }

    .moon-times,
    .moon-apsides {
        justify-content: center;
    }

    .moon-supermoon {
        align-items: center;
    }

    .tide-chart-container {
        height: 180px;
        padding: 0.75rem;
    }

    .tide-list {
        grid-template-columns: 1fr 1fr;
    }

    .tide-item {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
}

@media (min-width: 768px) {
    .container {
        padding: 2rem;
    }

    header {
        padding: 2rem 0;
    }

    header h1 {
        font-size: 2.5rem;
    }

    section {
        padding: 2rem;
    }

    .moon-visual {
        width: 160px;
        height: 160px;
    }

    .tide-chart-container {
        height: 250px;
    }

    .tide-list {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Loading State */
.loading {
    opacity: 0.6;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Error State */
.error {
    color: #ff6b6b;
    text-align: center;
    padding: 1rem;
}

/* Station Selection UI */
.station-selection-overlay {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
    min-height: 100vh;
}

.station-selection-modal {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.station-selection-modal h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-align: center;
}

.selection-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.station-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.station-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 1rem;
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.2);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
    color: inherit;
    font-family: inherit;
}

.station-option:hover {
    background: rgba(74, 158, 255, 0.2);
    border-color: rgba(74, 158, 255, 0.4);
    transform: translateY(-1px);
}

.station-name {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
}

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

.selection-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.cancel-link {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-decoration: none;
}

.cancel-link:hover {
    color: var(--accent-blue);
    text-decoration: underline;
}

/* Error Container */
.error-container {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    max-width: 500px;
    margin: 2rem auto;
    text-align: center;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.error-container h2 {
    color: var(--high-tide);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.error-message {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.error-link {
    color: var(--accent-blue);
    text-decoration: none;
}

.error-link:hover {
    text-decoration: underline;
}

/* Search Button */
.search-button,
.location-button,
.date-button,
.app-switch-button,
.help-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem 0.4rem;
    margin-left: 0.3rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    vertical-align: middle;
    opacity: 0.7;
}

.help-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1.5px solid var(--text-secondary);
    border-radius: 50%;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0;
}

.search-button:hover,
.location-button:hover,
.date-button:hover,
.app-switch-button:hover,
.help-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.date-button.active {
    background-color: rgba(255, 215, 0, 0.14);
    opacity: 1;
}

.help-button.active {
    opacity: 1;
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.location-button.loading {
    animation: pulse 1s ease-in-out infinite;
    cursor: wait;
}

/* Help Mode */
.help-block,
.help-section {
    display: none;
}

.help-mode-active .help-block,
.help-mode-active .help-section {
    display: block;
}

.help-block {
    background: rgba(74, 158, 255, 0.08);
    border: 1px solid rgba(74, 158, 255, 0.2);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    animation: helpFadeIn 0.3s ease;
}

.help-block p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 0.5rem;
}

.help-block p:last-child {
    margin-bottom: 0;
}

.help-block strong {
    color: var(--text-primary);
}

/* Colored emphasis for "golden hour" / "blue hour" in help text */
.help-block .hl-golden,
.help-block .hl-golden a {
    color: var(--accent-gold);
}

.help-block .hl-blue {
    color: var(--accent-blue);
}

.help-section {
    animation: helpFadeIn 0.3s ease;
}

.help-lead {
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.help-lead strong {
    color: var(--text-primary);
}

.help-text {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.help-text:last-child {
    margin-bottom: 0;
}

.help-text strong {
    color: var(--text-primary);
}

.help-feature-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0;
}

.help-feature {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.help-feature-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    width: 2rem;
    text-align: center;
    padding-top: 0.1rem;
}

.help-feature div {
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-feature strong {
    color: var(--text-primary);
}

.help-code {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background: rgba(74, 158, 255, 0.15);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
    color: var(--accent-blue);
}

@keyframes helpFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Geo-only mode - hide tide-related sections */
.geo-only-mode .tide-section,
.geo-only-mode .walk-section {
    display: none;
}

/* No station message for geo-only mode */
.no-station-message {
    background: rgba(255, 165, 0, 0.1);
    border: 1px solid rgba(255, 165, 0, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    margin-top: 1rem;
}

.no-station-message .message-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.no-station-message .message-title {
    color: var(--accent-gold);
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.no-station-message .message-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.no-station-message .search-link {
    display: inline-block;
    margin-top: 1rem;
    color: var(--accent-blue);
    text-decoration: none;
    padding: 0.5rem 1rem;
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.no-station-message .search-link:hover {
    background: rgba(74, 158, 255, 0.2);
    border-color: rgba(74, 158, 255, 0.5);
}

/* Date Picker Popover */
.date-popover-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding: 5.5rem 1rem 1rem;
}

.date-popover-overlay.visible {
    display: flex;
}

.date-popover {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 1.1rem;
    width: min(100%, 320px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.45);
    animation: modalSlideIn 0.2s ease;
}

.date-popover h2 {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.85rem;
    text-align: center;
}

.date-popover input {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}

.date-popover input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.date-popover-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.9rem;
}

.date-submit,
.date-cancel {
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.55rem 0.85rem;
    transition: all 0.2s ease;
}

.date-submit {
    background: var(--accent-blue);
    border: none;
    color: white;
    font-weight: 500;
}

.date-submit:hover {
    background: #5aa8ff;
}

.date-cancel {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
}

.date-cancel:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* Search Modal */
.search-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
    overflow-y: auto;
}

.search-modal-overlay.visible {
    display: flex;
}

.search-modal {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-modal h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-align: center;
}

.search-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.search-input-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-input-container input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}

.search-input-container input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.search-input-container input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.search-submit {
    padding: 0.75rem 1.5rem;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-submit:hover {
    background: #5aa8ff;
}

.search-submit:disabled {
    background: #555;
    cursor: not-allowed;
}

.search-results {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.search-results .station-list {
    max-height: none;
}

.search-results .search-error {
    color: var(--high-tide);
    text-align: center;
    padding: 1rem;
}

.search-results .search-loading {
    color: var(--text-secondary);
    text-align: center;
    padding: 1rem;
}

.search-footer {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.search-cancel {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    padding: 0.5rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.search-cancel:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* ============================================================
   Sun Dashboard (sun.html)
   ============================================================ */

/* Daylight / max-altitude summary band */
.sun-daylight {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    margin-bottom: 1rem;
}

.sun-stat {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.sun-stat-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sun-stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-gold);
}

/* Sun & twilight times grid */
.sun-times-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}

/* Wide screens: three columns so the nine cells group into three rows —
   [astro/nautical/civil dawn] · [sunrise/culmination/sunset] · [civil/nautical/astro dusk] */
@media (min-width: 600px) {
    .sun-times-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.sun-time-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.55rem 0.7rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.sun-time-item.emphasis {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.sun-time-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sun-time-value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.sun-time-item.emphasis .sun-time-value {
    color: var(--accent-gold);
}

/* Sun position + compass */
.sun-position-display {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.compass-visual {
    flex-shrink: 0;
    width: 150px;
    height: 150px;
}

#compassCanvas {
    width: 100%;
    height: 100%;
}

.sun-position-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.sun-position-status {
    font-size: 0.85rem;
    color: var(--low-tide);
}

.sun-position-status.below {
    color: var(--text-secondary);
}

/* Shadow */
.shadow-block {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.shadow-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.shadow-title {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.shadow-control {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

#shadowHeightInput {
    width: 4rem;
    padding: 0.3rem 0.45rem;
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
}

#shadowHeightInput:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.shadow-unit {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.shadow-result {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.3rem 0.8rem;
}

.shadow-result.below {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.shadow-ratio {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--accent-gold);
}

.shadow-abs {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.shadow-bar {
    margin-top: 0.6rem;
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.shadow-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), #f5b301);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Sun-path chart */
.sun-path-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 0.75rem;
    height: 220px;
    position: relative;
}

#sunPathChart {
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* Golden & blue hour */
.golden-blue-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.gb-column h3 {
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
}

.gb-window {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.6rem;
    border-left: 3px solid transparent;
}

.gb-window.golden {
    background: rgba(255, 184, 77, 0.12);
    border-left-color: #ffb84d;
}

.gb-window.blue {
    background: rgba(74, 120, 255, 0.12);
    border-left-color: #6f8dff;
}

.gb-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.gb-range {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Solar eclipse */
.eclipse-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.85rem;
    margin-bottom: 0.6rem;
}

.eclipse-badge {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border: none;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: #0a1628;
    background: var(--text-secondary);
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.1s ease;
}

.eclipse-badge:hover {
    filter: brightness(1.08);
}

.eclipse-badge:active {
    transform: scale(0.97);
}

.eclipse-badge.total {
    background: #ff6b6b;
    color: #fff;
}

.eclipse-badge.annular {
    background: #ffb84d;
}

.eclipse-badge.partial {
    background: #4a9eff;
    color: #fff;
}

.eclipse-when {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.eclipse-obscuration {
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 0.85rem;
}

.eclipse-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.eclipse-table th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.eclipse-table td {
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    vertical-align: top;
}

.eclipse-table .eclipse-contact {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
}

.eclipse-contact-name {
    font-weight: 500;
}

.eclipse-contact-note {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.eclipse-table .eclipse-peak-row td {
    background: rgba(255, 215, 0, 0.08);
}

.eclipse-table td.below {
    color: var(--text-secondary);
}

.eclipse-note {
    margin-top: 0.75rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Sunrise/Sunset row inserted into the eclipse table when the sun crosses the horizon mid-eclipse */
.eclipse-table .eclipse-horizon-row td {
    background: rgba(255, 184, 77, 0.13);
}

.eclipse-table .eclipse-horizon-row .eclipse-contact-name {
    color: var(--accent-gold);
}

/* Eclipse-day banner (links to the eclipse card) */
.eclipse-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.25rem;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.22), rgba(255, 184, 77, 0.22));
    border: 1px solid rgba(255, 184, 77, 0.5);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.05rem;
    text-decoration: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: helpFadeIn 0.3s ease;
}

.eclipse-banner:hover {
    text-decoration: none;
    border-color: var(--accent-gold);
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.3), rgba(255, 184, 77, 0.3));
}

.eclipse-banner:visited {
    color: var(--text-primary);
}

.eclipse-banner[hidden] {
    display: none;
}

.eclipse-banner-icon {
    font-size: 1.3rem;
}

.eclipse-banner-cta {
    margin-left: auto;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.embed-mode .eclipse-banner {
    display: none;
}

/* Coordinate entry in the location modal */
.coord-entry {
    margin: 0.5rem 0 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.coord-entry-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-align: center;
}

.coord-input-row {
    display: flex;
    gap: 0.5rem;
}

.coord-input-row input {
    flex: 1;
    min-width: 0;
    padding: 0.65rem 0.75rem;
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
}

.coord-input-row input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.coord-submit {
    padding-left: 1rem;
    padding-right: 1rem;
    flex-shrink: 0;
}

/* Date + time popover fields */
.date-popover-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}

.date-popover-field span {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* App-switch icon link (sun ⇄ moon) in the top icon bar */
.app-switch-button {
    display: inline-block;
    text-decoration: none;
    line-height: 1;
}

.app-switch-button:hover,
.app-switch-button:visited {
    text-decoration: none;
    color: inherit;
}

/* Embed mode — show only the requested sun card */
.embed-mode .sun-times-section,
.embed-mode .sun-position-section,
.embed-mode .sun-path-section,
.embed-mode .golden-blue-section,
.embed-mode .eclipse-section {
    display: none;
}

.embed-suntimes .sun-times-section,
.embed-sunposition .sun-position-section,
.embed-sunpath .sun-path-section,
.embed-goldenblue .golden-blue-section,
.embed-eclipse .eclipse-section {
    display: block;
}

/* Sun dashboard — responsive */
@media (max-width: 480px) {
    .sun-position-display {
        flex-direction: column;
        text-align: center;
    }

    .golden-blue-grid {
        grid-template-columns: 1fr;
    }

    .eclipse-table {
        font-size: 0.82rem;
    }

    .eclipse-table th,
    .eclipse-table td {
        padding: 0.4rem 0.35rem;
    }
}

@media (min-width: 768px) {
    .sun-path-container {
        height: 280px;
    }

    .compass-visual {
        width: 170px;
        height: 170px;
    }
}
