@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Sora:wght@500;600;700&display=swap');

:root {
    color-scheme: light;
    --bg: #f4f6fb;
    --bg-elevated: #ffffff;
    --bg-soft: #eef2f8;
    --text: #111827;
    --text-muted: #5a6478;
    --line: #dde3ef;
    --primary: #0f766e;
    --primary-strong: #115e59;
    --accent: #0ea5e9;
    --danger: #dc2626;
    --warning: #f59e0b;
    --success: #059669;
    --shadow-soft: 0 12px 28px rgba(20, 32, 60, 0.08);
    --shadow-hard: 0 24px 64px rgba(12, 20, 42, 0.18);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-pill: 999px;
    --page-max: 1320px;
    --space-1: 0.4rem;
    --space-2: 0.7rem;
    --space-3: 1rem;
    --space-4: 1.4rem;
    --space-5: 1.9rem;
    --space-6: 2.6rem;
    --space-7: 3.5rem;
}

html[data-theme='dark'],
html.night-mode,
body.night-mode {
    color-scheme: dark;
    --bg: #05070d;
    --bg-elevated: #0f1626;
    --bg-soft: #111b2d;
    --text: #edf2ff;
    --text-muted: #9daccc;
    --line: #22314a;
    --primary: #34d399;
    --primary-strong: #10b981;
    --accent: #38bdf8;
    --danger: #f87171;
    --warning: #fbbf24;
    --success: #34d399;
    --shadow-soft: 0 14px 34px rgba(0, 0, 0, 0.35);
    --shadow-hard: 0 26px 72px rgba(0, 0, 0, 0.55);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: 'Manrope', sans-serif;
    background: radial-gradient(circle at 15% -10%, rgba(15, 118, 110, 0.18), transparent 36%),
                radial-gradient(circle at 86% 0%, rgba(14, 165, 233, 0.17), transparent 38%),
                var(--bg);
    color: var(--text);
    line-height: 1.55;
}

h1,
h2,
h3,
h4,
h5,
h6,
.navbar-brand {
    font-family: 'Sora', sans-serif;
    letter-spacing: 0.01em;
    color: var(--text);
}

a {
    color: var(--accent);
    text-decoration: none;
}

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

.site-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 1200;
    backdrop-filter: blur(18px);
    background: var(--bg-elevated);
    background: color-mix(in oklab, var(--bg-elevated) 88%, transparent);
    border-bottom: 1px solid var(--line);
}

.seleno-nav {
    padding: 0.35rem 0;
}

.seleno-nav-inner {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0.25rem var(--space-4);
}

.seleno-brand {
    font-weight: 700;
    font-size: 1.08rem;
    color: var(--text);
}

.navbar-nav .nav-link {
    color: var(--text-muted);
    font-weight: 600;
    border-radius: 999px;
    padding: 0.45rem 0.95rem;
    transition: color 180ms ease, background-color 180ms ease;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus,
.navbar-nav .nav-link.active {
    color: var(--text);
    background: color-mix(in oklab, var(--primary) 20%, transparent);
}

.navbar-toggler {
    border: 1px solid var(--line);
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem color-mix(in oklab, var(--accent) 35%, transparent);
}

/* Theme-aware toggler icon: Bootstrap bakes a fixed stroke color into the default
   icon, which goes invisible against a dark header without the navbar-dark class. */
.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(17,24,39,0.85)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

html[data-theme='dark'] .navbar-toggler-icon,
body.night-mode .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(237,242,255,0.92)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid var(--line);
    background: var(--bg-elevated);
    color: var(--text);
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 700;
}

.theme-toggle-track {
    width: 38px;
    height: 20px;
    border-radius: 999px;
    background: color-mix(in oklab, var(--text-muted) 50%, transparent);
    padding: 2px;
    display: inline-flex;
    align-items: center;
}

.theme-toggle-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transform: translateX(0);
    transition: transform 180ms ease;
}

html[data-theme='dark'] .theme-toggle-thumb,
html.night-mode .theme-toggle-thumb,
body.night-mode .theme-toggle-thumb {
    transform: translateX(18px);
}

.theme-toggle-label {
    color: var(--text-muted);
    line-height: 1;
}

.dropdown-menu {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-soft);
    background: var(--bg-elevated);
}

.dropdown-item {
    color: var(--text);
    border-radius: 8px;
    margin: 0.1rem 0.35rem;
    padding: 0.45rem 0.65rem;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: color-mix(in oklab, var(--primary) 18%, transparent);
    color: var(--text);
}

.site-main {
    flex: 1;
    padding: var(--space-5) 0 var(--space-6);
}

.app-container {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.flash-stack {
    margin-bottom: var(--space-4);
}

.alert {
    border-radius: 12px;
    border: 1px solid transparent;
}

.site-footer {
    border-top: 1px solid var(--line);
    background: color-mix(in oklab, var(--bg-elevated) 93%, transparent);
}

.footer-inner {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 1rem var(--space-4) 1.25rem;
    text-align: center;
    color: var(--text-muted);
}

.footer-inner p {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.45rem;
    font-weight: 600;
}

.footer-inner small {
    display: block;
    margin-top: 0.35rem;
}

.footer-inner a {
    color: var(--text-muted);
}

.footer-inner a:hover {
    color: var(--text);
}

.card,
.panel,
.table,
.form-control,
.form-select,
.modal-content {
    border-color: var(--line);
}

.card,
.panel,
.modal-content,
.table {
    background: var(--bg-elevated);
    color: var(--text);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
}

.table {
    overflow: hidden;
}

.table th,
.table td {
    border-color: var(--line);
    color: var(--text);
}

.form-control,
.form-select,
textarea {
    border-radius: 10px;
    background: var(--bg-elevated);
    color: var(--text);
}

.form-control:focus,
.form-select:focus {
    border-color: color-mix(in oklab, var(--accent) 60%, #ffffff);
    box-shadow: 0 0 0 0.2rem color-mix(in oklab, var(--accent) 28%, transparent);
}

.btn {
    border-radius: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.btn-close {
    opacity: 0.7;
}

html[data-theme='dark'] .btn-close,
body.night-mode .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(140deg, var(--primary), var(--accent));
    border: none;
    box-shadow: 0 10px 24px color-mix(in oklab, var(--primary) 32%, transparent);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(140deg, var(--primary-strong), var(--accent));
}

.btn-ghost {
    border: 1px solid var(--line);
    background: color-mix(in oklab, var(--bg-elevated) 90%, transparent);
    color: var(--text);
}

.btn-ghost:hover,
.btn-ghost:focus {
    border-color: color-mix(in oklab, var(--accent) 40%, var(--line));
    color: var(--text);
}

.btn-outline-light {
    border-color: var(--line);
    color: var(--text);
}

.btn-outline-light:hover {
    border-color: var(--accent);
    background: color-mix(in oklab, var(--accent) 18%, transparent);
    color: var(--text);
}

.text-muted {
    color: var(--text-muted) !important;
}

.table a:not(.btn),
.table a:link:not(.btn),
.table a:visited:not(.btn) {
    color: inherit;
    text-decoration: underline;
}

.table a:not(.btn):hover,
.table a:not(.btn):focus {
    color: inherit;
}

/* --- Dark-mode compatibility layer ---
   Many existing templates use raw Bootstrap utility classes (bg-white, bg-light,
   text-dark) which set colors with !important. These attribute selectors patch
   them for dark mode without needing to edit every template individually. */
html[data-theme='dark'] [class~="bg-white"],
body.night-mode [class~="bg-white"] {
    background-color: var(--bg-elevated) !important;
    color: var(--text) !important;
}

html[data-theme='dark'] [class~="bg-light"],
body.night-mode [class~="bg-light"] {
    background-color: var(--bg-soft) !important;
    color: var(--text) !important;
}

html[data-theme='dark'] [class~="text-dark"],
body.night-mode [class~="text-dark"] {
    color: var(--text) !important;
}

html[data-theme='dark'] .draggable-panel,
html[data-theme='dark'] .main-panel,
body.night-mode .draggable-panel,
body.night-mode .main-panel {
    background-color: var(--bg-elevated) !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
}

/* Re-skin Bootstrap tables via its own CSS variables so striping/hover states
   (which read --bs-table-* internally) match the theme regardless of cascade order. */
html[data-theme='dark'] .table,
body.night-mode .table {
    --bs-table-bg: var(--bg-elevated);
    --bs-table-color: var(--text);
    --bs-table-striped-bg: var(--bg-soft);
    --bs-table-striped-color: var(--text);
    --bs-table-hover-bg: var(--bg-soft);
    --bs-table-hover-color: var(--text);
    --bs-table-border-color: var(--line);
}

html[data-theme='dark'] .alert,
body.night-mode .alert {
    --bs-alert-bg: var(--bg-soft);
    --bs-alert-color: var(--text);
    --bs-alert-border-color: var(--line);
    background-color: var(--bg-soft);
    color: var(--text);
    border-color: var(--line);
}

html[data-theme='dark'] .modal-content,
body.night-mode .modal-content {
    --bs-modal-bg: var(--bg-elevated);
    --bs-modal-color: var(--text);
    --bs-modal-header-border-color: var(--line);
    --bs-modal-footer-border-color: var(--line);
}

/* Main home dashboard */
.home-dashboard {
    display: grid;
    gap: var(--space-6);
}

.home-hero {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: 52vh;
    background: #02060f;
    box-shadow: var(--shadow-hard);
    border: 1px solid color-mix(in oklab, var(--line) 80%, transparent);
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
}

.home-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, rgba(3, 9, 20, 0.85) 10%, rgba(3, 9, 20, 0.4) 56%, rgba(3, 9, 20, 0.06) 90%);
    pointer-events: none;
}

.home-hero-copy {
    position: relative;
    z-index: 1;
    padding: clamp(1.6rem, 3.8vw, 3.2rem);
    align-self: center;
    max-width: 640px;
}

.home-eyebrow {
    color: #7dd3fc;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.11em;
    font-size: 0.75rem;
    margin-bottom: 0.8rem;
}

.home-hero h1 {
    color: #f7fbff;
    font-size: clamp(1.7rem, 3.5vw, 3rem);
    margin-bottom: 0.9rem;
}

.home-subtitle {
    color: rgba(236, 246, 255, 0.86);
    margin-bottom: 1.3rem;
    max-width: 52ch;
}

.home-hero-actions {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.home-hero-media {
    position: relative;
}

.home-hero-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-4);
}

.home-card {
    display: block;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-soft);
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
    color: var(--text);
}

.home-card:hover,
.home-card:focus {
    transform: translateY(-3px);
    border-color: color-mix(in oklab, var(--accent) 48%, var(--line));
    box-shadow: var(--shadow-hard);
    color: var(--text);
}

.home-card h2 {
    margin: 0 0 0.55rem;
    font-size: 1.1rem;
}

.home-card p {
    margin: 0;
    color: var(--text-muted);
}

/* Landing page */
.landing-body {
    margin: 0;
    min-height: 100vh;
    background: #010308;
    color: #eef7ff;
}

.landing-shell {
    width: 100%;
}

.landing-topbar {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 120;
    padding: 0.95rem clamp(1rem, 2.5vw, 2.2rem);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, rgba(2, 6, 15, 0.7), rgba(2, 6, 15, 0));
}

.landing-brand {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    color: #f8fdff;
    letter-spacing: 0.08em;
}

.landing-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.landing-skip,
.landing-enter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.42);
    color: #ecf5ff;
    background: rgba(5, 18, 35, 0.4);
    border-radius: 999px;
    padding: 0.45rem 0.95rem;
    font-weight: 700;
    font-size: 0.82rem;
}

.landing-enter {
    margin-top: 0.7rem;
}

.landing-panel {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: clamp(1rem, 4vw, 3rem);
}

.landing-video {
    position: absolute;
    inset: -5%;
    width: 110%;
    height: 110%;
    object-fit: cover;
    filter: saturate(1.08) contrast(1.07) brightness(0.72);
    will-change: transform;
}

.landing-gradient {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 78% 50%, rgba(5, 10, 30, 0.08), rgba(5, 10, 30, 0.65) 50%, rgba(2, 6, 15, 0.88));
}

.landing-content {
    position: relative;
    z-index: 2;
    max-width: 720px;
    padding: clamp(1rem, 2.5vw, 2rem);
    border-radius: var(--radius-lg);
    background: linear-gradient(140deg, rgba(1, 12, 28, 0.55), rgba(3, 22, 44, 0.2));
    border: 1px solid rgba(163, 193, 223, 0.18);
    box-shadow: var(--shadow-hard);
    backdrop-filter: blur(3px);
    will-change: transform;
}

.landing-kicker {
    margin: 0 0 0.45rem;
    color: #7dd3fc;
    font-size: 0.77rem;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    font-weight: 700;
}

.landing-content h1,
.landing-content h2 {
    color: #f6fbff;
    font-size: clamp(1.7rem, 4.2vw, 3.1rem);
    margin-bottom: 0.8rem;
}

.landing-content p {
    color: rgba(238, 246, 255, 0.86);
    max-width: 52ch;
}

.landing-finale .landing-content {
    border-color: rgba(255, 255, 255, 0.27);
}

/* Compatibility for existing interface panels */
.main-panel,
.draggable-panel,
.popup-panel {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
}

.panel-header {
    border-radius: 10px 10px 0 0;
}

.histogram-panel-canvas,
.star-map-canvas {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg-soft);
}

.photo.selected {
    border: 2px solid var(--accent) !important;
}

/* Media */
@media (max-width: 1120px) {
    .home-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .home-hero {
        grid-template-columns: 1fr;
        min-height: 480px;
    }

    .home-hero-media {
        min-height: 220px;
    }
}

@media (max-width: 768px) {
    .seleno-nav-inner,
    .app-container,
    .footer-inner {
        padding-left: var(--space-3);
        padding-right: var(--space-3);
    }

    .theme-toggle-label {
        display: none;
    }

    .home-grid {
        grid-template-columns: 1fr;
    }

    .landing-content {
        max-width: 100%;
    }

    .landing-skip {
        display: none;
    }
}

@media (max-width: 540px) {
    .site-main {
        padding-top: var(--space-4);
    }

    .landing-topbar {
        padding: 0.8rem 0.9rem;
    }

    .landing-content h1,
    .landing-content h2 {
        font-size: 1.55rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
