:root {
    --bg0: #070a12;
    --bg1: #0b1020;
    --card: rgba(255, 255, 255, 0.06);
    --card2: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.12);
    --text: #eaf0ff;
    --muted: rgba(234, 240, 255, 0.68);
    --accent: #7c3aed; /* purple */
    --accent2: #22d3ee; /* cyan */
    --good: #34d399;
    --warn: #fbbf24;
    --bad: #fb7185;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}
html,
body {
    min-height: 100%;
}
html {
    min-height: 100%;
    background:
        radial-gradient(
            85vmax 60vmax at 15% -10%,
            rgba(124, 58, 237, 0.35),
            transparent 60%
        ),
        radial-gradient(
            75vmax 55vmax at 90% 15%,
            rgba(34, 211, 238, 0.18),
            transparent 55%
        ),
        radial-gradient(
            80vmax 60vmax at 40% 120%,
            rgba(16, 185, 129, 0.16),
            transparent 60%
        ),
        linear-gradient(180deg, var(--bg0), var(--bg1));
    background-repeat: no-repeat;
    background-attachment: scroll;
}

html::before {
    content: "";
    position: fixed;
    inset: -25%;
    pointer-events: none;
    z-index: 0;

    background:
        radial-gradient(
            60vmax 45vmax at 20% 10%,
            rgba(124, 58, 237, 0.22),
            transparent 62%
        ),
        radial-gradient(
            55vmax 40vmax at 85% 20%,
            rgba(34, 211, 238, 0.14),
            transparent 60%
        ),
        radial-gradient(
            70vmax 50vmax at 45% 95%,
            rgba(16, 185, 129, 0.12),
            transparent 62%
        );

    transform: translate3d(0, 0, 0) scale(1.02);
    transform-origin: 50% 50%;
    will-change: transform;
    backface-visibility: hidden;

    animation: nebulaFloat 22s ease-in-out infinite;
}

@keyframes nebulaFloat {
    0% {
        transform: translate3d(0, 0, 0) scale(1.02);
    }
    50% {
        transform: translate3d(-2.2%, 1.6%, 0) scale(1.1);
    }
    100% {
        transform: translate3d(0, 0, 0) scale(1.02);
    }
}

@media (prefers-reduced-motion: reduce) {
    html::before {
        animation: none;
    }
}

html::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.06;

    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
    background-size: 260px 260px;

    mix-blend-mode: soft-light;
    z-index: 1;
}

body {
    min-height: 100%;
    margin: 0;
    font-family:
        ui-sans-serif,
        system-ui,
        -apple-system,
        Segoe UI,
        Roboto,
        Arial,
        "Apple Color Emoji",
        "Segoe UI Emoji";
    color: var(--text);
    position: relative;
    overflow-x: hidden;
    line-height: 1.45;
    background: transparent;
}

.container,
.card,
#results,
header,
main,
footer {
    position: relative;
    z-index: 2;
}

a {
    color: inherit;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 18px 60px;
}

.hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.title-wrap h1 {
    margin: 0;
    font-size: clamp(24px, 3vw, 34px);
    letter-spacing: 0.2px;
}

.muted {
    color: var(--muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 999px;
    font-size: 13px;
    white-space: nowrap;
}

.badge-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: radial-gradient(
        circle at 30% 30%,
        var(--accent2),
        var(--accent)
    );
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18);
}

.layout {
    display: grid;
    grid-template-columns: 1.35fr 0.65fr;
    gap: 16px;
    align-items: start;
}

@media (max-width: 960px) {
    .layout {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.06),
        rgba(255, 255, 255, 0.02)
    );
}
.card-header h2 {
    margin: 0;
    font-size: 14px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(234, 240, 255, 0.78);
}

#map {
    height: 460px;
    border-radius: 0 0 var(--radius) var(--radius);
}
/* Leaflet rounding */
.leaflet-container {
    background: rgba(255, 255, 255, 0.02);
}
.leaflet-control-attribution {
    background: rgba(0, 0, 0, 0.35) !important;
    color: rgba(255, 255, 255, 0.75) !important;
    border-radius: 10px;
    padding: 2px 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Form styling (works with form.as_p) */
form .fields {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

form p {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
label {
    font-size: 13px;
    color: rgba(234, 240, 255, 0.8);
}

input[type="text"],
input[type="datetime-local"],
input[type="number"],
select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(10, 14, 30, 0.55);
    color: var(--text);
    outline: none;
    transition:
        border 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.05s ease;
}
input:focus,
select:focus {
    border-color: rgba(124, 58, 237, 0.6);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.18);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.btn {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition:
        transform 0.06s ease,
        background 0.15s ease,
        border 0.15s ease;
    user-select: none;
}
.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.22);
}
.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    border-color: rgba(124, 58, 237, 0.55);
    background: linear-gradient(
        135deg,
        rgba(124, 58, 237, 0.35),
        rgba(34, 211, 238, 0.16)
    );
}
.btn-primary:hover {
    border-color: rgba(124, 58, 237, 0.85);
    background: linear-gradient(
        135deg,
        rgba(124, 58, 237, 0.44),
        rgba(34, 211, 238, 0.2)
    );
}

.submit-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-flex;
}
.loading-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(234, 240, 255, 0.85);
    font-size: 13px;
}
.spinner {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: rgba(255, 255, 255, 0.85);
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#results {
    margin-top: 16px;
}

.readout {
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 14px;
}
.readout p {
    margin: 6px 0;
}
.readout code {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 8px;
}

.readout.error {
    border-color: rgba(251, 113, 133, 0.45);
    background: rgba(251, 113, 133, 0.1);
}

h2 {
    margin: 14px 0 10px;
    font-size: 18px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
}
thead th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(234, 240, 255, 0.78);
    background: rgba(255, 255, 255, 0.06);
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
tbody td {
    padding: 11px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(234, 240, 255, 0.9);
    text-align: center;
}
tbody tr:hover td {
    background: rgba(124, 58, 237, 0.1);
}
tbody tr:last-child td {
    border-bottom: 0;
}

.help {
    margin: 10px 0 0;
    font-size: 13px;
    color: rgba(234, 240, 255, 0.7);
}

/* Make hidden inputs not create layout gaps if rendered */
input[type="hidden"] {
    display: none;
}

.full .ts-control {
    background: rgba(10, 14, 30, 0.55);
}
.ts-wrapper .ts-control {
    background: rgba(10, 14, 30, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    padding: 8px 10px;
    color: var(--text);
}
.ts-wrapper.focus .ts-control {
    border-color: rgba(124, 58, 237, 0.6);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.18);
}
.ts-dropdown {
    background: rgba(8, 10, 18, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    overflow: hidden;
}
.ts-dropdown .option {
    color: rgba(234, 240, 255, 0.92);
    padding: 10px 12px;
}
.ts-dropdown .option.active {
    background: rgba(124, 58, 237, 0.22);
}
.ts-dropdown .create {
    color: rgba(234, 240, 255, 0.72);
}
.htmx-indicator {
    opacity: 0;
    visibility: hidden;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
    visibility: visible;
    transition: opacity 200ms ease-in;
}

/* Leaflet popup styling */
.leaflet-popup-content-wrapper {
    background: rgba(8, 10, 18, 0.92);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.55);
}

.leaflet-popup-tip {
    background: rgba(8, 10, 18, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

/* tighter popup content */
.leaflet-popup-content {
    margin: 10px 12px;
    line-height: 1.25;
    font-size: 13px;
}

/* custom popup card */
.lp-popup .title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.lp-popup .title strong {
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(234, 240, 255, 0.82);
}

.lp-popup .chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    font-weight: 700;
}

.lp-popup .meta {
    color: rgba(234, 240, 255, 0.72);
}

.lp-popup code {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 8px;
}
/* THIS BETTER WORK*/
/* Links should not look like default underlined hyperlinks */
a {
    color: inherit;
    text-decoration: none;
}

/* Header bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100; /* above nebula/noise/content */
    background: rgba(7, 10, 18, 0.72);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 240px;
}

.brand-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: radial-gradient(
        circle at 30% 30%,
        var(--accent2),
        var(--accent)
    );
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18);
    flex: 0 0 auto;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-title {
    font-weight: 800;
    letter-spacing: 0.2px;
    color: rgba(234, 240, 255, 0.95);
}

.brand-sub {
    font-size: 12px;
    color: rgba(234, 240, 255, 0.62);
    margin-top: 3px;
}

/* Nav pills */
.nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(234, 240, 255, 0.92);
    font-weight: 700;
    font-size: 13px;
    transition:
        transform 0.06s ease,
        background 0.15s ease,
        border 0.15s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.22);
}

.nav-item:active {
    transform: translateY(1px);
}

.nav-item.active {
    border-color: rgba(124, 58, 237, 0.55);
    background: linear-gradient(
        135deg,
        rgba(124, 58, 237, 0.3),
        rgba(34, 211, 238, 0.12)
    );
}

/* Mobile tweaks */
@media (max-width: 720px) {
    .topbar-inner {
        align-items: flex-start;
    }
    .brand {
        min-width: 0;
    }
}

.table-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 10px 0 12px;
    flex-wrap: wrap;
}

.table-search {
    width: min(520px, 100%);
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(10, 14, 30, 0.55);
    color: var(--text);
    outline: none;
    transition:
        border 0.15s ease,
        box-shadow 0.15s ease;
}

.table-search:focus {
    border-color: rgba(124, 58, 237, 0.6);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.18);
}

.table-count {
    font-size: 13px;
    color: var(--muted);
}

.cloud-forecast {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.cloud-forecast-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.cloud-forecast-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

@media (max-width: 900px) {
    .cloud-forecast-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (max-width: 520px) {
    .cloud-forecast-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.cloud-pill {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 10px 10px;
    text-align: center;
}

.cloud-pill .t {
    font-size: 12px;
    color: rgba(234, 240, 255, 0.7);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.cloud-pill .v {
    font-weight: 800;
    font-size: 16px;
}
/* ===========================
   Mobile optimization patch
   Paste at bottom of star_form.css
   =========================== */

@media (max-width: 900px) {
    .container {
        padding: 18px 14px 44px;
    }

    .hero {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 14px;
    }

    .title-wrap h1 {
        font-size: clamp(22px, 5.2vw, 30px);
        line-height: 1.15;
    }

    /* Slightly tighter card headers */
    .card-header {
        padding: 12px 14px;
    }
}

/* Header + nav: keep it one line, scrollable */
@media (max-width: 720px) {
    .topbar-inner {
        padding: 10px 14px;
        gap: 10px;
    }

    .brand {
        gap: 8px;
    }

    .brand-title {
        font-size: 14px;
    }

    .brand-sub {
        font-size: 11px;
    }

    .nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding-bottom: 4px; /* gives a little room for scroll */
        scrollbar-width: none; /* Firefox hide */
    }
    .nav::-webkit-scrollbar {
        display: none; /* Chrome/Safari hide */
    }

    .nav-item {
        white-space: nowrap;
        padding: 7px 10px;
        font-size: 12px;
    }
}

/* Main layout: make sure map + options stack nicely */
@media (max-width: 960px) {
    .layout {
        gap: 12px;
    }
}

/* Map height: smaller on phones */
@media (max-width: 720px) {
    #map {
        height: 320px;
    }
}
@media (max-width: 420px) {
    #map {
        height: 280px;
    }
}

/* Form controls: grid buttons on mobile so they don't wrap awkwardly */
@media (max-width: 720px) {
    form .fields {
        padding: 12px 14px;
        gap: 10px;
    }

    .controls {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .btn {
        width: 100%;
        justify-content: center;
        padding: 10px 12px;
    }

    .submit-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .loading-pill {
        width: 100%;
        justify-content: center;
    }
}

/* Search + count: stack nicely */
@media (max-width: 720px) {
    .table-tools {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .table-search {
        width: 100%;
    }

    .table-count {
        text-align: right;
    }
}

/* Tables: make them scroll instead of squishing columns */
@media (max-width: 720px) {
    .readout {
        padding: 12px 12px;
    }

    /* wrap any table in a scroll area */
    .readout table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    thead th,
    tbody td {
        padding: 10px 9px;
        font-size: 13px;
    }

    thead th {
        font-size: 11px;
    }
}

/* Forecast pills: fewer columns on smaller screens */
@media (max-width: 720px) {
    .cloud-forecast-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (max-width: 420px) {
    .cloud-forecast-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Fix your hideSmall rule: it currently includes grid-template-columns accidentally */

@media (max-width: 600px) {
    .hideSmall {
        display: none;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.cloud-pill .temp {
    font-size: 13px;
    margin-top: 4px;
    color: rgba(234, 240, 255, 0.75);
}
