body, html { margin: 0; padding: 0; height: 100%; background-color: black; font-family: sans-serif; overflow: hidden; transition: background-color 0.3s; }

/* DARK MODE (DEFAULT) */
#menu-btn {
    position: absolute; top: 15px; left: 15px;
    background: rgba(0, 0, 0, 0.6);
    color: cyan;
    border: 1px solid cyan;
    border-radius: 4px;
    font-size: 20px;
    padding: 0 12px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s;
    box-sizing: border-box;
}
#menu-btn:hover { background: rgba(0, 255, 255, 0.2); }

/* THEME TOGGLE BUTTON */
#theme-btn {
    position: absolute; top: 15px; right: 15px;
    background: rgba(0, 0, 0, 0.6);
    color: cyan;
    border: 1px solid cyan;
    border-radius: 4px;
    font-size: 20px;
    padding: 0;
    height: 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s;
    line-height: 1;
    box-sizing: border-box;
}
#theme-btn:hover { background: rgba(0, 255, 255, 0.2); }

/* ROTATION TOGGLE BUTTON */
#rotate-btn {
    position: absolute; top: 15px; right: 65px;
    background: rgba(0, 0, 0, 0.6);
    color: cyan;
    border: 1px solid cyan;
    border-radius: 4px;
    font-size: 18px;
    padding: 0;
    height: 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s;
    line-height: 1;
    box-sizing: border-box;
}
#rotate-btn:hover { background: rgba(0, 255, 255, 0.2); }

/* RESET VIEW BUTTON */
#reset-btn {
    position: absolute; top: 15px; right: 115px;
    background: rgba(0, 0, 0, 0.6);
    color: cyan;
    border: 1px solid cyan;
    border-radius: 4px;
    font-size: 20px;
    padding: 0;
    height: 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s;
    line-height: 1;
    box-sizing: border-box;
}
#reset-btn:hover { background: rgba(0, 255, 255, 0.2); }

/* GPS BUTTON */
#gps-btn {
    position: absolute; top: 15px; right: 165px;
    background: rgba(0, 0, 0, 0.6);
    color: cyan;
    border: 1px solid cyan;
    border-radius: 4px;
    padding: 0;
    height: 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s;
    box-sizing: border-box;
}
#gps-btn svg {
    width: 20px;
    height: 20px;
    stroke: cyan;
    fill: none;
    stroke-width: 2;
}
#gps-btn circle.inner {
    fill: cyan;
    stroke: none;
}
#gps-btn:hover { background: rgba(0, 255, 255, 0.2); }

/* CROSS-SECTION DRAG OVERLAY — transparent full-screen capture layer */
#cs-drag-overlay {
    position: fixed; inset: 0;
    z-index: 1003;
    display: none;
    cursor: crosshair;
}

/* CROSS-SECTION BUTTON */
#cs-btn {
    position: absolute; top: 15px; right: 365px;
    background: rgba(0, 0, 0, 0.6);
    color: cyan;
    border: 1px solid cyan;
    border-radius: 4px;
    padding: 0;
    height: 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s;
    box-sizing: border-box;
}
#cs-btn svg { width: 20px; height: 20px; }
#cs-btn:hover { background: rgba(0, 255, 255, 0.2); }
#cs-btn.active { color: #ff8c00; border-color: #ff8c00; }

/* CROSS-SECTION PANEL */
#cs-panel {
    position: fixed; bottom: 20px; left: 20px;
    width: clamp(280px, 35vw, 500px);
    background: rgba(15, 15, 15, 0.92);
    border: 1px solid #333;
    border-radius: 6px;
    padding: 10px 12px 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    z-index: 999;
    display: none;
    box-sizing: border-box;
}
#cs-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 4px;
}
#cs-title {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: #777;
}
#cs-close {
    background: none; border: none; color: #555; cursor: pointer;
    font-size: 16px; padding: 0; line-height: 1; margin-left: 4px;
}
#cs-close:hover { color: white; }
#cs-status {
    font-size: 10px; color: #888; margin-bottom: 6px; min-height: 14px;
}
#cs-focus-btn {
    display: none;
    background: transparent; border: none;
    color: rgba(255,200,0,0.75);
    font-size: 11px; cursor: pointer; padding: 0 4px;
    transition: color 0.2s;
}
#cs-focus-btn:hover { color: rgba(255,200,0,1); }
#cs-canvas { display: block; width: 100%; height: 150px; }

/* LIVE MODE BUTTON */
#live-btn {
    position: absolute; top: 15px; right: 315px;
    background: rgba(0, 0, 0, 0.6);
    color: cyan;
    border: 1px solid cyan;
    border-radius: 4px;
    padding: 0;
    height: 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s;
    box-sizing: border-box;
}
#live-btn svg { width: 20px; height: 20px; }
#live-btn:hover { background: rgba(0, 255, 255, 0.2); }
#live-btn.active {
    color: #ff8c00;
    border-color: #ff8c00;
    animation: live-glow 2s ease-in-out infinite;
}
@keyframes live-glow {
    0%, 100% { box-shadow: 0 0 6px rgba(255, 140, 0, 0.4); }
    50%       { box-shadow: 0 0 14px rgba(255, 140, 0, 0.8); }
}

/* MAG CHART BUTTON */
#mag-chart-btn {
    position: absolute; top: 15px; right: 265px;
    background: rgba(0, 0, 0, 0.6);
    color: cyan;
    border: 1px solid cyan;
    border-radius: 4px;
    padding: 0;
    height: 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s;
    box-sizing: border-box;
}
#mag-chart-btn:hover { background: rgba(0, 255, 255, 0.2); }
#mag-chart-btn svg { width: 18px; height: 18px; fill: cyan; }

/* MAG CHART PANEL */
#mag-chart-panel {
    position: fixed; bottom: 20px; right: 20px;
    width: clamp(280px, 35vw, 500px);
    background: rgba(15, 15, 15, 0.92);
    border: 1px solid #333;
    border-radius: 6px;
    padding: 10px 12px 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    z-index: 999;
    display: block;
    box-sizing: border-box;
}
#mag-chart-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 6px;
}
#mag-chart-title {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: #777;
}
#mag-chart-close {
    background: none; border: none; color: #555; cursor: pointer;
    font-size: 16px; padding: 0; line-height: 1;
}
#mag-chart-close:hover { color: white; }
#mag-chart { display: block; width: 100%; }

/* TIMELAPSE BUTTON (MOVED TO HEADER) */
#timelapse-mode-btn {
    position: absolute; top: 15px; right: 215px; /* Left of GPS (165 + 50) */
    background: rgba(0, 0, 0, 0.6);
    color: cyan;
    border: 1px solid cyan;
    border-radius: 4px;
    font-size: 20px;
    padding: 0;
    height: 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s;
    line-height: 1;
    box-sizing: border-box;
}
#timelapse-mode-btn:hover { background: rgba(0, 255, 255, 0.2); }

#side-panel {
    position: fixed;
    top: 0; left: -340px;
    width: 300px;
    height: 100%;
    background: rgba(20, 20, 20, 0.95);
    border-right: 1px solid #333;
    box-shadow: 2px 0 15px rgba(0,0,0,0.8);
    z-index: 1002;
    transition: left 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), background-color 0.3s;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

#side-panel.open { left: 0; }

#close-btn {
    position: absolute; top: 15px; right: 15px;
    background: none; border: none; color: #666;
    font-size: 24px; cursor: pointer;
}
#close-btn:hover { color: white; }

h2 { margin: 0 0 20px 0; font-size: 22px; color: cyan; border-bottom: 1px solid #333; padding-bottom: 15px; }
h3 { margin: 20px 0 10px 0; font-size: 14px; color: #888; text-transform: uppercase; border-bottom: 1px solid #444; padding-bottom: 5px; }
h3:first-of-type { margin-top: 0; }

.control-group { margin-bottom: 15px; width: 100%; }

label { display: block; font-size: 12px; margin-bottom: 5px; color: #aaa; font-weight: bold; text-transform: uppercase; letter-spacing: 0.5px;}
span.val { color: white; float: right; }

input[type=range] {
    width: 100%; cursor: pointer; accent-color: cyan;
    height: 4px; background: #444; border-radius: 2px;
}

input[type=date], input[type=text], input[type=number] {
    width: 100%; background: #333; color: white; border: 1px solid #555;
    padding: 5px; border-radius: 3px; font-family: sans-serif;
    box-sizing: border-box;
}

/* Search Box Specifics */
.search-container { display: flex; gap: 5px; }
.search-btn {
    background: #444; color: cyan; border: 1px solid #555; cursor: pointer;
    padding: 5px 10px; border-radius: 3px; font-weight: bold; text-transform: uppercase;
    font-size: 11px; transition: all 0.2s;
}
.search-btn:hover { background: #555; border-color: cyan; }
.search-btn:disabled {
    opacity: 0.5; cursor: not-allowed; background: #333; color: #888; border-color: #555;
}

.checkbox-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #333;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #555;
    margin-bottom: 15px;
}
.checkbox-group label { margin: 0; cursor: pointer; color: white; }
input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; accent-color: cyan; }
label.checkbox-label { display: flex; align-items: center; gap: 6px; margin-bottom: 0; cursor: pointer; }

.preset-group { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 15px; }
.preset-btn {
    flex: 1 1 30%; background: #333; color: #ddd; border: 1px solid #555;
    padding: 8px 5px; font-size: 11px; cursor: pointer; border-radius: 3px;
    transition: all 0.2s; text-transform: uppercase; font-weight: bold;
    white-space: nowrap;
}
.preset-btn:hover { background: #444; border-color: cyan; color: cyan; }

select {
    background: #333; color: white; border: 1px solid #555;
    padding: 8px; border-radius: 3px; width: 100%; font-size: 13px; cursor: pointer;
}

#load-btn, #render-btn {
    width: 100%; background: cyan; color: black; border: none;
    padding: 10px; font-weight: bold; cursor: pointer;
    margin-bottom: 20px; border-radius: 4px;
    text-transform: uppercase; letter-spacing: 1px;
    transition: background 0.2s;
}
#load-btn:hover, #render-btn:hover { background: #ccffff; }

#chart-container { height: 100vh; width: 100%; }

#info-overlay {
    position: absolute; bottom: 15px; left: 15px;
    color: rgba(255,255,255,0.5); font-size: 11px;
    pointer-events: none; user-select: none;
    z-index: 5;
    background: rgba(0,0,0,0.5);
    padding: 5px 10px;
    border-radius: 4px;
    transition: color 0.3s;
}

#loading {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: cyan; font-size: 24px; font-weight: bold;
    background: rgba(0,0,0,0.8); padding: 20px; border-radius: 10px; z-index: 2000;
}

/* POPUP STYLES */
#quake-info {
    position: absolute; top: 60px; right: 15px;
    width: 250px;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid cyan;
    border-radius: 4px;
    padding: 15px;
    color: white;
    display: none;
    z-index: 1005;
    box-shadow: 0 0 15px rgba(0,0,0,0.8);
    font-family: sans-serif;
    animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

#quake-info h3 {
    margin: 0 0 10px 0; color: cyan; font-size: 15px; border-bottom: 1px solid #444; padding-bottom: 5px;
    line-height: 1.3;
}
#quake-info p { margin: 6px 0; font-size: 13px; color: #ccc; }
#quake-info strong { color: white; }
#quake-info a {
    display: block; margin-top: 12px; color: black; background: cyan;
    text-align: center; padding: 8px; text-decoration: none;
    border-radius: 3px; font-weight: bold; font-size: 12px; transition: background 0.2s;
}
#quake-info a:hover { background: #ccffff; }
#quake-info-close {
    position: absolute; top: 5px; right: 10px; cursor: pointer; color: #666; font-size: 18px; font-weight: bold;
}
#quake-info-close:hover { color: white; }

/* SIMULATE BUTTON */
#qi-sim-btn {
    display: block; width: 100%; margin-top: 8px;
    background: transparent; color: cyan;
    border: 1px solid cyan; border-radius: 3px;
    padding: 8px; text-transform: uppercase; font-weight: bold; font-size: 11px;
    cursor: pointer; transition: all 0.2s;
}
#qi-sim-btn:hover { background: rgba(0, 255, 255, 0.1); }

/* --- TIME LAPSE CONTROLS --- */
#timelapse-bar {
    position: fixed;
    bottom: 30px; left: 50%;
    transform: translateX(-50%);
    width: 90%; max-width: 600px;
    background: rgba(20, 20, 20, 0.9);
    border: 1px solid cyan;
    border-radius: 8px;
    padding: 15px;
    display: none; /* Hidden by default */
    flex-direction: column;
    gap: 10px;
    z-index: 1004;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

#timelapse-bar.active { display: flex; }

.tl-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

#tl-date-display {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    color: cyan;
    min-width: 180px;
    text-align: center;
}

#tl-play-btn {
    background: none; border: 1px solid cyan; color: cyan;
    width: 40px; height: 30px; cursor: pointer; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
#tl-play-btn:hover { background: rgba(0, 255, 255, 0.2); }

#tl-close-btn {
    background: none; border: none; color: #666; cursor: pointer; font-size: 18px;
}
#tl-close-btn:hover { color: white; }

#tl-scrubber { width: 100%; accent-color: cyan; cursor: pointer; }

.tl-select {
    background: #333; color: white; border: 1px solid #555;
    padding: 4px; border-radius: 3px; font-size: 11px;
}

.tl-options-row { font-size: 11px; color: #888; justify-content: flex-start; }
.tl-trail-label { display: inline; margin-right: 5px; margin-bottom: 0; }
.tl-window-select { width: auto; }

.tl-toggle { margin-left: 15px; display: flex; align-items: center; }
.tl-toggle input[type=checkbox] { width: 14px; height: 14px; margin-right: 5px; }
.tl-toggle label { margin: 0; cursor: pointer; }

/* Render section */
#resume-container {
    display: none;
    margin-bottom: 15px;
    padding: 10px;
    background: #331111;
    border: 1px solid #ff4444;
    border-radius: 4px;
}
#resume-header { color: #ff8888; font-size: 11px; margin-bottom: 5px; font-weight: bold; }
#resume-text { color: #ddd; font-size: 11px; margin-bottom: 8px; }
#resume-btn {
    width: 100%; background: #ff4444; color: white; border: none;
    padding: 8px; border-radius: 3px; cursor: pointer;
    font-weight: bold; text-transform: uppercase;
}

.render-file-row { display: flex; gap: 5px; }
#filename-pattern { flex: 2; }
#render-format { flex: 1; }

.render-frame-row { display: flex; gap: 10px; align-items: center; }
#frame-slider { flex: 2; }
#frame-number { width: 70px; flex: 1; text-align: right; }


/* --- LIGHT MODE OVERRIDES --- */
body.light-mode {
    background-color: #f0f0f0; /* Off-white background */
    color: #333; /* Dark grey text */
}
body.light-mode #side-panel {
    background: rgba(255, 255, 255, 0.95); /* Translucent white panel */
    border-right: 1px solid #ccc;
    box-shadow: 2px 0 15px rgba(0,0,0,0.1);
}
body.light-mode #menu-btn {
    background: rgba(255, 255, 255, 0.9);
    color: #008080; /* Teal accent */
    border-color: #008080;
}
body.light-mode #menu-btn:hover {
    background: rgba(0, 128, 128, 0.1);
}
body.light-mode #mag-chart-btn {
    background: rgba(255, 255, 255, 0.9); border-color: #333;
}
body.light-mode #mag-chart-btn:hover { background: rgba(0, 0, 0, 0.05); }
body.light-mode #mag-chart-btn svg { fill: #333; }
body.light-mode #mag-chart-panel {
    background: rgba(255, 255, 255, 0.95); border-color: #ccc;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
body.light-mode #mag-chart-title { color: #999; }
body.light-mode #mag-chart-close { color: #bbb; }
body.light-mode #mag-chart-close:hover { color: #333; }
body.light-mode #live-btn {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border-color: #333;
}
body.light-mode #live-btn:hover { background: rgba(0, 0, 0, 0.05); }
body.light-mode #live-btn.active { color: #ff8c00; border-color: #ff8c00; }

body.light-mode #cs-btn {
    background: rgba(255, 255, 255, 0.9); color: #333; border-color: #333;
}
body.light-mode #cs-btn:hover { background: rgba(0, 0, 0, 0.05); }
body.light-mode #cs-btn.active { color: #ff8c00; border-color: #ff8c00; }
body.light-mode #cs-panel {
    background: rgba(255, 255, 255, 0.95); border-color: #ccc;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
body.light-mode #cs-title { color: #999; }
body.light-mode #cs-close { color: #bbb; }
body.light-mode #cs-close:hover { color: #333; }
body.light-mode #cs-status { color: #888; }
body.light-mode #cs-focus-btn { color: rgba(180,120,0,0.8); }
body.light-mode #cs-focus-btn:hover { color: #cc8800; }

body.light-mode #theme-btn, body.light-mode #rotate-btn, body.light-mode #reset-btn, body.light-mode #gps-btn, body.light-mode #timelapse-mode-btn {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border-color: #333;
}
body.light-mode #theme-btn:hover, body.light-mode #rotate-btn:hover, body.light-mode #reset-btn:hover, body.light-mode #gps-btn:hover, body.light-mode #timelapse-mode-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}
body.light-mode #gps-btn svg {
    stroke: #333;
}
body.light-mode #gps-btn circle.inner {
    fill: #333;
}

body.light-mode h2 {
    color: #008080; /* Teal accent */
    border-bottom-color: #ccc;
}
body.light-mode h3 {
    color: #666;
    border-bottom-color: #ddd;
}
body.light-mode label {
    color: #555;
}
body.light-mode span.val {
    color: #333;
}
body.light-mode input[type=date],
body.light-mode input[type=text],
body.light-mode input[type=number],
body.light-mode select,
body.light-mode .tl-select {
    background: white;
    color: #333;
    border-color: #bbb;
}
body.light-mode .checkbox-group {
    background: white;
    border-color: #bbb;
}
body.light-mode .checkbox-group label {
    color: #333;
}
body.light-mode .preset-btn {
    background: white;
    color: #333;
    border-color: #bbb;
}
body.light-mode .preset-btn:hover {
    background: #e6f2f2;
    border-color: #008080;
    color: #008080;
}
body.light-mode input[type=range] {
    background: #ddd;
    accent-color: #008080; /* Teal accent */
}
body.light-mode #load-btn, body.light-mode #render-btn {
    background: #008080; /* Teal accent */
    color: white;
}
body.light-mode #load-btn:hover, body.light-mode #render-btn:hover {
    background: #006666; /* Darker teal on hover */
}
body.light-mode .search-btn {
    background: #f0f0f0;
    color: #008080;
    border-color: #ccc;
}
body.light-mode .search-btn:hover {
    background: #e0e0e0;
}
body.light-mode .search-btn:disabled {
    background: #eee; color: #aaa; border-color: #ddd; cursor: not-allowed;
}
body.light-mode #info-overlay {
    background: rgba(255, 255, 255, 0.85);
    color: #333;
    border: 1px solid #ddd;
}

/* Popup Light Mode */
body.light-mode #quake-info {
    background: rgba(255, 255, 255, 0.95);
    border-color: #008080;
    color: #333;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
}
body.light-mode #quake-info h3 {
    color: #008080;
    border-bottom-color: #eee;
}
body.light-mode #quake-info p {
    color: #555;
}
body.light-mode #quake-info strong {
    color: #333;
}
body.light-mode #quake-info a {
    background: #008080;
    color: white;
}
body.light-mode #quake-info a:hover {
    background: #006666;
}
body.light-mode #close-btn:hover {
    color: #333;
}
body.light-mode #qi-sim-btn {
    color: #008080; border-color: #008080;
}
body.light-mode #qi-sim-btn:hover {
    background: rgba(0, 128, 128, 0.1);
}
/* Loading Overlay Light Mode */
body.light-mode #loading {
    background: rgba(255, 255, 255, 0.95);
    color: #008080;
    border: 1px solid #008080;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
}

/* Time Lapse Light Mode */
body.light-mode #timelapse-bar {
    background: rgba(255, 255, 255, 0.9);
    border-color: #008080;
    color: #333;
}
body.light-mode #tl-date-display, body.light-mode #tl-play-btn {
    color: #008080;
}
body.light-mode #tl-play-btn { border-color: #008080; }
body.light-mode #tl-play-btn:hover { background: rgba(0, 128, 128, 0.1); }
body.light-mode #resume-container { background: #ffe6e6; border-color: #eebbbb; }
body.light-mode #resume-header { color: #cc0000; }
body.light-mode #resume-text { color: #333; }
body.light-mode #resume-btn { background: #ff4444; color: white; }
body.light-mode #resume-btn:hover { background: #cc0000; }

#pulse-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
}
