/* ── Night Sky Report — Global Styles ────────────────────────────────────── */

:root {
    --bg-deepest: #0b0f19;
    --bg-dark: #0f172a;
    --bg-card: #111827;
    --bg-card-alt: #1a1f2e;
    --bg-card-alt2: #151a27;
    --border: #1e293b;
    --border-light: #2d3548;

    --text-primary: #f1f5f9;
    --text-secondary: #e2e8f0;
    --text-tertiary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --text-faintest: #475569;

    --accent-purple: #7c3aed;
    --accent-purple-light: #a78bfa;
    --accent-blue: #60a5fa;
    --accent-cyan: #22d3ee;
    --accent-green: #22c55e;
    --accent-yellow: #eab308;
    --accent-orange: #f97316;
    --accent-red: #ef4444;
    --accent-pink: #f472b6;
    --accent-emerald: #34d399;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --user-bubble-bg: #2e1065;
}

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

body {
    background: var(--bg-deepest);
    font-family: var(--font-family);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* ── Search Section ─────────────────────────────────────────────────────── */

.search-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(30, 27, 75, 0.4) 0%, transparent 60%),
        var(--bg-deepest);
}

.search-container {
    width: 100%;
    max-width: 520px;
    text-align: center;
}

.search-header {
    margin-bottom: 36px;
}

.search-icon {
    font-size: 56px;
    margin-bottom: 12px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.search-header h1 {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.search-subtitle {
    font-size: 15px;
    color: var(--text-muted);
}

.search-form {
    position: relative;
}

.input-group {
    display: flex;
    gap: 8px;
    position: relative;
}

.location-input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    font-size: 15px;
    color: var(--text-primary);
    font-family: var(--font-family);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.location-input::placeholder {
    color: var(--text-faint);
}

.location-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

#target-search-input {
    padding-left: 42px;
}

.input-group.loading::after {
    content: '';
    position: absolute;
    right: 64px;
    top: 50%;
    margin-top: -8px;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    pointer-events: none;
    z-index: 5;
}

.btn-primary {
    background: var(--accent-purple);
    border: none;
    border-radius: var(--radius-md);
    padding: 0 16px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
    background: #6d28d9;
}

.btn-primary:active {
    transform: scale(0.95);
}

/* ── Suggestions Dropdown ─────────────────────────────────────────────── */

.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    z-index: 100;
    display: none;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.suggestions-dropdown.active {
    display: block;
}

.suggestion-item {
    padding: 12px 18px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    text-align: left;
}

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

.suggestion-item:hover,
.suggestion-item.selected {
    background: var(--bg-card-alt);
    color: var(--text-primary);
}

.suggestion-item .suggestion-name {
    font-weight: 600;
    color: var(--text-secondary);
}

.suggestion-item .suggestion-detail {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 2px;
}

/* ── Divider / Or ─────────────────────────────────────────────────────── */

.divider-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 20px 0;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider-text {
    font-size: 12px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ── Geolocation Button ───────────────────────────────────────────────── */

.btn-geolocation {
    width: 100%;
    background: var(--bg-card-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    font-family: var(--font-family);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.btn-geolocation:hover {
    background: var(--bg-card);
    border-color: var(--accent-purple);
}

.btn-geolocation:active {
    transform: scale(0.98);
}

.search-footer {
    margin-top: 32px;
    font-size: 11px;
    color: var(--text-faintest);
    line-height: 1.6;
}


/* ── Loading Overlay ────────────────────────────────────────────────────── */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 15, 25, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.loading-subtext {
    font-size: 13px;
    color: var(--text-muted);
    animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}


/* ── Report Container ───────────────────────────────────────────────────── */

.report-wrapper {
    background: var(--bg-deepest);
    padding: 20px 10px;
    display: flex;
    justify-content: center;
}

.report {
    width: 100%;
    max-width: 640px;
}


/* ── Back Button ────────────────────────────────────────────────────────── */

.back-bar {
    text-align: left;
    margin-bottom: 12px;
}

.btn-back {
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    font-family: var(--font-family);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-back:hover {
    background: var(--bg-card-alt);
    color: var(--text-primary);
    border-color: var(--accent-purple);
}


/* ── Report Header ──────────────────────────────────────────────────────── */

.report-header {
    position: relative;
    background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 50%, #0c1222 100%);
    border-radius: var(--radius-lg);
    padding: 24px 24px 2px 24px;
    margin-bottom: 24px;
    border: none !important;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.report-header.flush {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin-bottom: 0;
}

@media (max-width: 1024px) {
    .report-header-icon {
        position: absolute;
        top: 12px;
        right: 12px;
        z-index: 900;
        margin: 0;
    }
    
    body.chat-fullscreen-active .report-header-icon {
        display: none !important;
    }

    .header-spacer {
        display: none !important;
    }
}

.report-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.report-header-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0px;
}

.report-header-icon {
    display: flex;
    align-items: center;
}

.report-header h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin: 0;
    flex: 1;
    text-align: center;
}

.report-header-location {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1;
    margin-bottom: 4px;
}

.date-picker-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    position: relative;
    background-color: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    height: 36px;
    box-sizing: border-box;
    cursor: pointer;
    transition: all 0.2s ease;
}

.date-picker-wrapper:hover {
    border-color: var(--accent-purple);
    background-color: rgba(15, 23, 42, 0.9);
}

.date-picker-label {
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
    white-space: nowrap;
    user-select: none;
}

.date-picker-icon {
    flex-shrink: 0;
    opacity: 0.6;
}

/* The native input is invisible but still functional for the picker */
.date-picker-hidden {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.report-header-location {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-faint);
    margin-top: 10px;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    text-decoration: none !important;
    pointer-events: none;
    cursor: default;
    display: block;
}

/* ── UI Tiles (Standard Card) ───────────────────────────────────────────── */

.tile {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.tile:last-child {
    margin-bottom: 0;
}

.report-header-location:hover {
    color: var(--text-faint);
    text-decoration: none;
    cursor: default;
}

/* ── Model Selector (Segmented Control) ───────────────────────── */
.model-selector-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.model-selector-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-left: 4px;
}

.model-selector {
    display: flex;
    background: rgba(15, 23, 42, 0.4);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    padding: 3px;
    overflow: hidden;
    width: 100%;
}

.model-pill {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-faint);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-family);
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    border-radius: calc(var(--radius-sm) - 2px);
}

.model-pill:hover {
    color: var(--text-primary);
    background: rgba(124, 58, 237, 0.08);
}

.model-pill.active {
    background: var(--accent-purple);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}


/* ── Rating Banner ──────────────────────────────────────────────────────── */

.rating-banner {
    padding: 18px 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.rating-label-section {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.rating-label {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.rating-desc {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.rating-dots {
    margin-top: 8px;
    display: flex;
    gap: 4px;
}

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

.rating-moon-icon {
    font-size: 88px;
    line-height: 1;
    display: flex;
    align-items: center;
}


/* ── Quick Stats Row ────────────────────────────────────────────────────── */

.quick-stats {
    background: var(--bg-card);
    padding: 16px 0;
    display: flex;
}

.quick-stat {
    flex: 1;
    text-align: center;
    padding: 8px;
}

.quick-stat:not(:last-child) {
    border-right: 1px solid var(--border);
}

.quick-stat-label {
    font-size: 11px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.quick-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 4px;
}

.quick-stat-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}


/* ── Sun & Moon Section ─────────────────────────────────────────────────── */

.sun-moon-section {
    background: var(--bg-dark);
    padding: 20px 24px;
    display: flex;
    gap: 24px;
}

.sun-moon-col {
    flex: 1;
}

.sun-moon-col+.sun-moon-col {
    border-left: 1px solid var(--border);
    padding-left: 24px;
}

.section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.data-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 13px;
}

.data-label {
    color: var(--text-muted);
}

.data-value {
    color: var(--text-tertiary);
}

.data-value.highlight {
    color: var(--accent-purple-light);
    font-weight: 600;
}

.moon-interference {
    margin-top: 8px;
    font-size: 12px;
}


/* ── Weather Section ────────────────────────────────────────────────────── */

.weather-section {
    background: var(--bg-card);
    padding: 20px 24px;
    border-top: 1px solid var(--border);
}

.weather-cards {
    display: flex;
    gap: 8px;
}

.weather-card {
    flex: 1;
    text-align: center;
    padding: 10px;
    background: var(--bg-card-alt);
    border-radius: 10px;
}

.weather-card-icon {
    font-size: 24px;
}

.weather-card-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 4px;
}

.weather-card-label {
    font-size: 11px;
    color: var(--text-muted);
}

.weather-card-sub {
    font-size: 11px;
    color: var(--text-faint);
}

.hourly-chart-section {
    margin-top: 16px;
}

.hourly-chart-title {
    font-size: 11px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    text-align: center;
}

.hourly-chart {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 0;
    width: 100%;
}

.hourly-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 1px;
    flex: 1;
    min-width: 0;
}

.hourly-bar-pct {
    font-size: 9px;
    color: var(--text-muted);
    margin-bottom: 2px;
    letter-spacing: -0.2px;
}

.hourly-bar-fill {
    width: 100%;
    max-width: 50px;
    border-radius: 3px 3px 0 0;
    min-height: 2px;
}

.hourly-bar-time {
    font-size: 9px;
    color: var(--text-faint);
    margin-top: 3px;
    white-space: nowrap;
}


/* ── Temperature Chart ──────────────────────────────────────────────────── */

.temp-toggle-row {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.temp-toggle {
    display: flex;
    gap: 0;
    background: var(--bg-card-alt);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.temp-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-faint);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-family);
    padding: 5px 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.temp-toggle-btn:first-child {
    border-right: 1px solid var(--border-light);
}

.temp-toggle-btn.active {
    background: var(--accent-purple);
    color: white;
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.4);
}

.temp-toggle-btn:hover:not(.active) {
    color: var(--text-secondary);
    background: var(--bg-card-alt2);
}


/* ── Radar Section ────────────────────────────────────────────────────────── */

.radar-container {
    background: var(--bg-card-alt);
    border-radius: 12px;
    border: 1px solid var(--border-light);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.radar-title {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
}

.radar-iframe {
    width: 100%;
    height: 400px; /* JS overrides this via fitMapToViewport() */
    min-height: 400px;
    display: block;
    flex: 1;
}

#lp-map {
    width: 100%;
    height: 400px; /* JS overrides this via fitMapToViewport() */
    min-height: 400px;
    border-radius: 0 0 12px 12px;
}

.lp-wrapper {
    position: relative;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}


/* ── DSO Section ────────────────────────────────────────────────────────── */

.dso-section-header {
    background: var(--bg-dark);
    padding: 20px 24px 12px;
    border-top: 1px solid var(--border);
    margin-top: 10px;
}

.dso-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dso-section-subtitle {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 4px;
}

.dso-list {
    background: var(--bg-dark);
    padding: 0 24px 24px;
}

.dso-card {
    margin-bottom: 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dso-card:nth-child(odd) {
    background: var(--bg-card-alt);
}

.dso-card:nth-child(even) {
    background: var(--bg-card-alt2);
}

.dso-card-image {
    width: 100%;
    background: var(--bg-card);
    position: relative;
    border-bottom: 1px solid var(--border-light);
}

.dso-card-image img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.dso-card-image a {
    text-decoration: none;
}

.dso-card-placeholder {
    background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 90px;
}

.placeholder-icon {
    font-size: 32px;
    opacity: 0.5;
}

.placeholder-label {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 4px;
    opacity: 0.6;
}

.dso-card-body {
    padding: 12px 14px;
    flex: 1;
    min-width: 0;
}

.dso-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.dso-name .designation {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 13px;
}

.dso-badges {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.dso-type-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}

.dso-mag {
    color: var(--text-muted);
    font-size: 12px;
}

.dso-size {
    color: var(--text-muted);
    font-size: 12px;
}

.dso-dot-sep {
    color: var(--text-faint);
    font-size: 12px;
}

.dso-timing {
    font-size: 12px;
    color: var(--text-tertiary);
}

.dso-timing div {
    padding: 1px 0;
}

.dso-notes {
    font-size: 11px;
    color: var(--text-faint);
    font-style: italic;
    margin-top: 4px;
}

.dso-settings {
    margin-top: 8px;
    font-size: 11px;
    border-collapse: collapse;
    width: 100%;
    max-width: 320px;
}

.dso-settings th {
    padding: 3px 6px;
    color: var(--text-faint);
    font-weight: 600;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}

.dso-settings th.col-altaz {
    color: var(--accent-blue);
    font-weight: 700;
    text-align: center;
    font-size: 10px;
    letter-spacing: 0.5px;
}

.dso-settings th.col-eq {
    color: var(--accent-purple-light);
    font-weight: 700;
    text-align: center;
    font-size: 10px;
    letter-spacing: 0.5px;
}

.dso-settings td {
    padding: 2px 6px;
    color: var(--text-muted);
}

.dso-settings td.val {
    color: var(--text-secondary);
    text-align: center;
    padding: 2px 8px;
}

.dso-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}


/* ── Report Footer ──────────────────────────────────────────────────────── */

.report-footer {
    background: var(--bg-deepest);
    border-top: 1px solid var(--border);
    padding: 20px 24px;
    text-align: center;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    font-size: 11px;
    color: var(--text-faintest);
    line-height: 1.7;
}


/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .search-header h1 {
        font-size: 26px;
    }

    .search-icon {
        font-size: 44px;
    }

    .sun-moon-section {
        flex-direction: column;
        gap: 16px;
    }

    .sun-moon-col+.sun-moon-col {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid var(--border);
        padding-top: 16px;
    }

    .hourly-bar {
        padding: 0;
    }

    .hourly-bar-fill {
        width: 20px;
    }

    .report-header {
        padding: 24px 20px 20px;
    }

    .rating-banner {
        padding: 14px 20px;
    }

    .weather-section,
    .sun-moon-section,
    .dso-section-header,
    .dso-list {
        padding-left: 16px;
        padding-right: 16px;
    }
}


/* ── Desktop Layout ────────────────────────────────────────────────────── */

@media (min-width: 900px) {

    /* Wider report container */
    .report {
        max-width: 960px;
    }

    .report-wrapper {
        padding: 32px 24px;
    }

    /* Larger header */
    .report-header {
        padding: 40px 40px 28px;
    }

    .report-header-icon {
        font-size: 48px;
    }

    .report-header h2 {
        font-size: 30px;
    }

    .report-header-date {
        font-size: 15px;
    }

    .report-header-location {
        font-size: 13px;
    }

    /* Larger model selector */
    .model-pill {
        font-size: 13px;
        padding: 7px 22px;
    }

    /* Rating banner */
    .rating-banner {
        padding: 24px 32px;
    }

    .rating-label {
        font-size: 26px;
    }

    .rating-desc {
        font-size: 14px;
    }

    .rating-moon-icon {
        font-size: 96px;
    }

    /* Quick stats */
    .quick-stats {
        padding: 20px 0;
    }

    .quick-stat {
        padding: 12px 16px;
    }

    .quick-stat-label {
        font-size: 12px;
    }

    .quick-stat-value {
        font-size: 28px;
    }

    .quick-stat-sub {
        font-size: 12px;
    }

    /* Sun & Moon */
    .sun-moon-section {
        padding: 28px 32px;
    }

    .data-row {
        font-size: 14px;
    }

    /* Weather */
    .weather-section {
        padding: 28px 32px;
    }

    .weather-card {
        padding: 18px 14px;
    }

    .weather-card-value {
        font-size: 20px;
    }

    /* Hourly charts */
    .hourly-charts {
        padding: 0 32px 28px;
    }

    /* DSO Section */
    .dso-section-header {
        padding: 28px 32px 16px;
    }

    .dso-section-title {
        font-size: 14px;
    }

    .dso-section-subtitle {
        font-size: 13px;
    }

    /* DSO grid: two columns */
    .dso-list {
        padding: 0 32px 32px;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .dso-card {
        margin-bottom: 0;
    }

    .dso-card-image img {
        height: 140px;
    }

    .dso-card-placeholder {
        height: 140px;
        min-height: 140px;
    }

    .dso-card-body {
        padding: 14px 16px;
    }

    /* Empty state should span both columns */
    .dso-empty {
        grid-column: 1 / -1;
    }

    /* Footer */
    .report-footer {
        padding: 24px 32px;
        font-size: 13px;
    }

    /* Search section */
    .search-container {
        max-width: 580px;
    }

    .search-header h1 {
        font-size: 36px;
    }

    .search-icon {
        font-size: 60px;
    }

    .search-tagline {
        font-size: 15px;
    }

    .chat-container {
        height: calc(100dvh - 480px);
    }
}


/* ── Ultra-wide Desktop ────────────────────────────────────────────────── */

@media (min-width: 1200px) {

    .report {
        max-width: 1100px;
    }

    .report-wrapper {
        padding: 40px 32px;
    }

    /* 3-column DSO grid on very wide screens */
    .dso-list {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .dso-card-image img {
        height: 120px;
    }

    .dso-card-placeholder {
        height: 120px;
        min-height: 120px;
    }
}

/* ── Target Search & Sort Controls ───────────────────────────────────────── */

.target-controls {
    display: flex;
    flex-direction: column;
    gap: 24px;
    /* Inherit tile styling */
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
}

@media (min-width: 640px) {
    .target-controls {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end;
    }

    .model-selector-group {
        width: 100%;
    }

    .target-search-container {
        flex: 1;
    }
}

.target-sort-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.sort-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sort-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-left: 4px;
}

.sort-select {
    background: var(--bg-card-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: var(--font-family);
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 160px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 36px;
}

.sort-select:focus {
    border-color: var(--accent-purple);
    background: var(--bg-card-alt2);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.btn-sort-order {
    background: var(--bg-card-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    height: 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sort-order:hover {
    background: var(--bg-card-alt2);
    border-color: var(--accent-purple);
    color: var(--accent-purple-light);
}

.btn-sort-order:active {
    transform: scale(0.95);
}

/* ── Sidebar Navigation ────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: #0f172a;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 32px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    font-size: 28px;
}

.sidebar-menu {
    flex: 1;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: #94a3b8;
    background: transparent;
    border: none;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: left;
}

.sidebar-item svg {
    opacity: 0.7;
}

.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f1f5f9;
}

.sidebar-item.active {
    background: #7c3aed;
    color: #ffffff;
}

.sidebar-item.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 24px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-btn-new {
    color: #ef4444;
}

.sidebar-btn-new:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* PWA Install Button — stands out at the bottom of the sidebar */
.sidebar-btn-pwa {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.25), rgba(99, 102, 241, 0.15));
    border: 1px solid rgba(124, 58, 237, 0.5);
    color: #a78bfa;
    margin-bottom: 8px;
    border-radius: 12px;
}

.sidebar-btn-pwa:hover {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.4), rgba(99, 102, 241, 0.25));
    color: #c4b5fd;
    border-color: rgba(124, 58, 237, 0.8);
}

.sidebar-btn-pwa svg {
    opacity: 1 !important;
}

/* ── Page Splitting ────────────────────────────────────────────────────── */
.page-content {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.page-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Adjust report container for sidebar */
#report-container {
    padding-left: 260px;
    width: 100%;
}

/* Hide header location hover or cursor since it's no longer a link */
.report-header-location {
    cursor: default !important;
}

.report-header-location:hover,
.report-header-location:active,
.report-header-location:visited,
.report-header-location:focus {
    color: inherit !important;
    text-decoration: none !important;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

/* ── Mobile Sidebar (Off-canvas) ───────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        transform: translateX(-100%);
        flex-direction: column;
        padding: 0;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
        border-top: none;
        background: #0f172a;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex !important;
        /* Force flex but hidden by transform */
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }

    .sidebar-header {
        display: none;
    }

    .sidebar-menu {
        flex-direction: column;
        padding: 20px 12px 0;
        gap: 4px;
        align-items: stretch;
        justify-content: flex-start;
    }

    .sidebar-item {
        padding: 12px 16px;
        font-size: 15px;
        flex-direction: row;
        gap: 12px;
        width: 100%;
        border-radius: 12px;
    }

    .sidebar-item span {
        font-size: 15px;
    }

    .sidebar-footer {
        padding: 24px 12px;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        display: block;
        margin-top: auto;
        position: sticky;
        bottom: 0;
        background: #0f172a;
    }

    /* The invisible spacer perfectly centers the title between the left edge (hamburger menu) and the right logo */

    #report-container {
        padding-left: 0;
        padding-bottom: 0;
    }

    /* Hamburger Toggle Styles */
    .sidebar-toggle {
        display: none;
        position: fixed;
        top: 32px;
        left: 22px;
        z-index: 1100;
        background: rgba(15, 23, 42, 0.8);
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 10px;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        color: #f1f5f9;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .sidebar-toggle.chat-fs-active {
        position: fixed !important;
        top: 32px;
        left: 22px;
    }

    .sidebar-toggle.shifted {
        transform: translateX(274px); /* 280px - some padding */
    }

    /* Overlay styles */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(2px);
        z-index: 950;
        display: block !important;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.visible {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ── Astro Chat Section ─────────────────────────────────────────────────── */
.chat-container {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 380px);
    min-height: 300px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    margin: 0;
}

/* ── Chat Locked Layout (Auto-resize to fit viewport) ── */
.report-wrapper.chat-locked,
.report-wrapper.fill-mode {
    height: 100dvh;
    padding-top: 16px;
    padding-bottom: 0px;
}

.report-wrapper.chat-locked .report,
.report-wrapper.fill-mode .report {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.report-wrapper.chat-locked #page-chat.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.report-wrapper.chat-locked #page-chat.active .chat-container {
    flex: 1;
    min-height: 0;
    margin-bottom: 20px;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}



/* ── Mobile Fullscreen Chat Mode ────────────────────────────────────────── */
/* Applied when user taps the textarea on a small screen. Exits via the     */
/* hamburger menu button.                                                    */

@media (max-width: 899px) {
    #page-chat.chat-fullscreen {
        position: fixed;
        inset: 0;
        z-index: 1000;
        display: flex !important;
        flex-direction: column;
        background: var(--bg-deepest);
        animation: chatFadeIn 0.2s ease-out;
        padding: 0;
    }

    #page-chat.chat-fullscreen .tile {
        display: none; /* hide model selector to maximise chat space */
    }

    #page-chat.chat-fullscreen .chat-container {
        flex: 1;
        height: auto !important;
        max-height: none !important;
        min-height: 0;
        border-radius: 0;
        border: none;
        margin: 0;
    }
}

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



.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background:
        radial-gradient(circle at top right, rgba(124, 58, 237, 0.03), transparent 40%),
        radial-gradient(circle at bottom left, rgba(96, 165, 250, 0.03), transparent 40%);
}

/* Custom Scrollbar for Chat */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-faintest);
}

.chat-message {
    width: 100%;
    max-width: 100%;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}



.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.chat-message.bot .chat-avatar {
    background: linear-gradient(135deg, #4c1d95 0%, #1e1b4b 100%);
    border-color: rgba(167, 139, 250, 0.3);
    float: left;
    margin-right: 12px;
    margin-bottom: 4px;
}

.chat-message.user .chat-avatar {
    float: right;
    margin-left: 12px;
    margin-bottom: 4px;
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--text-secondary);
    position: relative;
    width: 100%;
    display: flow-root; /* contains floated avatars */
}

.chat-message.bot .chat-bubble {
    background: var(--bg-card-alt);
    border: 1px solid var(--border-light);
    border-top-left-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.chat-message.user .chat-bubble {
    background: var(--user-bubble-bg);
    color: white;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(46, 16, 101, 0.35);
}

/* Markdown styling inside bubbles */
.chat-bubble p {
    margin-top: 0;
    margin-bottom: 8px;
}

.chat-bubble p:last-child,
.chat-bubble p:first-child {
    margin-bottom: 0;
}

.chat-bubble ul {
    margin: 8px 0;
    padding-left: 20px;
}

.chat-bubble li {
    margin-bottom: 4px;
}

.chat-bubble strong {
    color: #fff;
    font-weight: 700;
}

.chat-message.user .chat-bubble strong {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Input Area */
.chat-input-wrapper {
    padding: 16px 20px;
    background: var(--bg-card-alt2);
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

#chat-textarea {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: var(--font-family);
    resize: none;
    outline: none;
    max-height: 120px;
    transition: all 0.2s;
    line-height: 1.5;
}

#chat-textarea:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
    background: var(--bg-dark);
}

#chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--accent-purple);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-bottom: 2px;
}

#chat-send-btn:hover:not(:disabled) {
    background: #6d28d9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

#chat-send-btn:active:not(:disabled) {
    transform: translateY(0);
}

#chat-send-btn:disabled {
    opacity: 0.4;
    background: var(--text-faintest);
    cursor: not-allowed;
}

/* Typing Indicator */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.chat-typing span {
    width: 6px;
    height: 6px;
    background: var(--text-faint);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.chat-typing span:nth-child(1) {
    animation-delay: -0.32s;
}

.chat-typing span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1.0);
    }
}

@media (max-width: 640px) {
    .chat-container {
        height: calc(100dvh - 280px);
        min-height: 250px;
        margin: 10px 0;
    }

    .report-wrapper.chat-locked #page-chat.active .chat-container {
        flex: 1;
        min-height: 0;
        margin: 0;
    }

    /* Change hamburger to back arrow and keep it perfectly transparent */
    #sidebar-toggle.chat-fs-active {
        opacity: 0.6;
        background: transparent;
        border: none;
    }
    #sidebar-toggle.chat-fs-active #icon-menu {
        display: none !important;
    }
    #sidebar-toggle.chat-fs-active #icon-back {
        display: block !important;
    }

    /* Removed mobile chat-message max-width override as it is now 100% globally */

    .chat-messages {
        padding: 16px;
    }
}

/* ── iOS PWA Modal ─────────────────────────────────────────────────────── */

.pwa-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.pwa-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    padding: 30px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.pwa-modal-header {
    margin-bottom: 24px;
}

.pwa-modal-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

.pwa-modal h2 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

.pwa-instructions {
    background: var(--bg-card-alt);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    text-align: left;
}

.pwa-step {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.pwa-step:last-child {
    margin-bottom: 0;
}

.pwa-step-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(124, 58, 237, 0.2);
    border-radius: 8px;
    color: var(--accent-purple-light);
    flex-shrink: 0;
}

.pwa-close-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent-purple);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pwa-close-btn:hover {
    background: #6d28d9;
    transform: translateY(-2px);
}