/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

:root {
    /* DEFAULT DARK THEME */
    --bg-dark: #000000;
    /* Canvas Background */
    --bg-panel: #1e1e1e;
    /* Sidebar Background */
    --text-main: #e0e0e0;
    --text-muted: #a0a0a0;
    --accent-blue: #2196F3;
    --accent-hover: #1976D2;
    --success-green: #4CAF50;
    --border-color: #333;
    --sidebar-width: 320px;
    --toggle-bg: rgba(30, 30, 30, 0.8);
    --bg-ticker: rgba(30, 30, 30, 0.9);
    /* Default Dark Ticker */
}

[data-theme="light"] {
    /* LIGHT THEME OVERRIDES */
    --bg-dark: #e0e0e0;
    /* Canvas Background - Light Gray */
    --bg-panel: #ffffff;
    /* Sidebar Background - White */
    --text-main: #1a1a1a;
    /* Dark Text */
    --text-muted: #555555;
    --border-color: #cccccc;
    --toggle-bg: rgba(255, 255, 255, 0.8);
    --bg-ticker: #d0d0d0;
    /* Light Gray Ticker for Light Mode */
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
}

/* Sidebar Toggle */
.sidebar-toggle {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 1000;
    background: var(--toggle-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    backdrop-filter: blur(4px);
    transition: background 0.3s, border-color 0.3s;
}

/* Theme Toggle */
.theme-toggle {
    position: absolute;
    top: 15px;
    left: 61px;
    /* Position: 15px (Menu Left) + 38px (Menu Width) + 8px (Gap) = 61px */
    z-index: 1000;
    background: var(--toggle-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    padding: 6px;
    /* Slightly smaller padding for icon */
    width: 34px;
    height: 34px;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    font-size: 1.2rem;
    transition: background 0.3s, border-color 0.3s, transform 0.3s ease, opacity 0.3s ease;
}

.theme-toggle:hover {
    border-color: var(--accent-blue);
}

/* GitHub Button (Floating) */
#githubBtn {
    left: 103px;
    /* Position: 61px (Theme Left) + 34px (Theme Width) + 8px (Gap) = 103px */
    color: var(--text-main);
    text-decoration: none;
}

/* GitHub Button (Floating) */
#githubBtn {
    left: 103px;
    /* Position: 61px (Theme Left) + 34px (Theme Width) + 8px (Gap) = 103px */
    color: var(--text-main);
    text-decoration: none;
}

#githubBtn:hover {
    color: var(--accent-blue);
}

/* Language Toggle (Floating) */
.lang-toggle {
    position: absolute;
    top: 15px;
    left: 145px;
    /* Position: 103px (GitHub Left) + 34px (GitHub Width) + 8px (Gap) = 145px */
    z-index: 1000;
    display: flex;
    background: var(--toggle-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    /* Capsule/Pill Shape */
    padding: 2px;
    backdrop-filter: blur(4px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    height: 34px;
    /* Match other buttons */
    align-items: center;
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 16px;
    /* Inner capsule */
    cursor: pointer;
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    align-items: center;
}

.lang-btn.active {
    background-color: var(--accent-blue);
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.lang-btn:hover:not(.active) {
    color: var(--text-main);
}

.sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text-main);
    transition: 0.3s;
}

.sidebar-toggle:hover span {
    background-color: var(--accent-blue);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 100;
    flex-shrink: 0;
    height: 100%;
    overflow-x: hidden !important;
    justify-content: flex-start;
    padding-top: 60px;
    /* Space for Top Bar Controls */
}

/* Undo/Redo Floating Group */
.undo-redo-floating {
    position: absolute;
    top: 15px;
    left: 240px;
    /* Aligned to right side of sidebar (320px - ~75px - 5px) */
    z-index: 1000;
    display: flex;
    gap: 6px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.undo-redo-floating .header-icon-btn {
    width: 34px;
    height: 34px;
    background: var(--toggle-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
}

.bmc-wrapper {
    position: absolute;
    bottom: 55px; /* Above the ticker */
    left: calc(var(--sidebar-width) + 15px);
    z-index: 1000;
    transition: left 0.3s ease;
    /* Scale down by 30% */
    transform: scale(0.65) translateY(0px);
    transform-origin: bottom left;
    
    /* Layout for two vertical buttons */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
}

/* Hover Animation exclusively for the Buy Me a Coffee Button */
.bmc-wrapper a:not(.playstore-button) {
    transition: transform 0.2s ease, filter 0.2s ease !important;
}

.bmc-wrapper a:not(.playstore-button):hover {
    transform: translateY(-4px) scale(1.04) !important;
    filter: brightness(1.1) drop-shadow(0 4px 6px rgba(0,0,0,0.2)) !important;
}

/* Custom Discord Button (Playstore Style) matching BMC configs */
.playstore-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff; /* Dark mode default border */
  border-radius: 9999px;
  background-color: #ffffff; /* Dark mode default bg */
  padding: 0.70rem; /* Adjusted for icon-only centering */
  text-align: center;
  color: #000000; /* Dark mode default text */
  outline: 0;
  transition: all 0.2s ease;
  text-decoration: none;
  font-family: 'Lato', 'Inter', sans-serif;
  box-sizing: border-box;
}

.playstore-button:hover {
  background-color: transparent;
  color: #ffffff;
}

/* Light Theme Overrides */
[data-theme="light"] .playstore-button {
  border-color: #000000;
  background-color: #000000;
  color: #ffffff;
}

[data-theme="light"] .playstore-button:hover {
  background-color: transparent;
  color: #000000;
}

.playstore-button .icon {
  height: 1.5rem;
  width: 1.5rem;
  fill: currentColor;
}

body.sidebar-closed .bmc-wrapper {
    left: 61px;
}

.undo-redo-floating .header-icon-btn:hover:not(.disabled) {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.undo-redo-floating .header-icon-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ... (other existing styles) ... */

/* Button Group - Restored Flex Layout */
.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.button-group>* {
    flex: 1;
}

.row-btn-group {
    flex: 1;
    display: flex;
}

/* Preset Category */
.preset-category {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 8px 0 6px 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Preset Popover - Floating Overlay */
.preset-popover {
    position: fixed;
    /* Independent of sidebar */
    width: 240px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    /* Above sidebar */
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.preset-popover.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Paint Popover overrides */
.paint-popover {
    width: 260px;
}

/* Paint button active style */
#paintModeBtn.paint-active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(33, 150, 243, 0.5);
}

.sidebar.hidden {
    transform: translateX(-100%);
    margin-right: calc(-1 * var(--sidebar-width));
}

/* Hide Floating Buttons when Sidebar is Closed */
body.sidebar-closed .theme-toggle,
body.sidebar-closed .undo-redo-floating,
body.sidebar-closed .lang-toggle {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    opacity: 0;
    pointer-events: none;
}

/* Sidebar Header */
.sidebar-header {
    height: 60px;
    /* Fixed height for consistency */
    padding: 0 15px;
    /* Horizontal padding only */
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    /* Prevent shrinking */
    margin-top: 50px;
    /* Space for absolute toggle buttons if needed */
}

/* Header Icon Buttons (GitHub, Undo, Redo) */
.header-icon-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    padding: 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    /* For anchor tags */
}

.header-icon-btn:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.header-icon-btn:active:not(.disabled) {
    transform: translateY(0);
}

.header-icon-btn.disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
    background: transparent;
    border-color: transparent;
}

.header-icon-btn svg {
    width: 100%;
    height: 100%;
    stroke-width: 2px;
    /* For Lucide style icons */
}

/* Undo/Redo Group */
.undo-redo-group {
    display: flex;
    gap: 5px;
    /* Exact 5px spacing request */
}

/* Sidebar Content */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 0 20px;
    /* Horizontal padding + Top padding for separation */
}

/* App Logo */
.sidebar-logo {
    margin-bottom: 20px;
    padding-bottom: 20px;
    /* border-bottom: 1px solid #444; REMOVED */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    /* Default align left */
    width: 100%;
    position: relative;
    /* margin-right: -14px; REMOVED */
}

.sidebar-logo::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -12px;
    /* 20px padding - 12px = 8px from edge */
    right: -12px;
    /* 20px padding - 12px = 8px from edge */
    height: 1px;
    background: #444;
}

.logo-main {
    font-family: 'Inter', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
    opacity: 0.9;
    background: linear-gradient(135deg, var(--text-main) 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.logo-sub {
    font-family: 'Inter', sans-serif;
    font-size: 1.0rem;
    /* Increased by ~5 units */
    font-weight: 400;
    color: var(--text-muted);
    align-self: flex-end;
    /* Bottom right alignment relative to container */
    margin-top: 2px;
    /* 2px gap as requested */
    margin-right: 0;
    /* Aligned with the end of the separator line */
    opacity: 0.7;
    font-style: italic;
}

/* Panels */
/* Panels */
.panel-section {
    position: relative;
    margin-bottom: 20px;
    /* Standardized spacing per request */
    padding-bottom: 20px;
    /* border-bottom: 1px solid #444; REMOVED for custom alignment */
}

/* Custom separator line aligned to Redo button (right: 6px) */
.panel-section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -12px;
    /* 20px padding - 12px = 8px from edge */
    right: -12px;
    /* 20px padding - 12px = 8px from edge */
    /* Align with 8px gap request */
    height: 1px;
    background: #444;
}

/* Remove border from the last section */
.sidebar-content>.panel-section:last-child::after {
    display: none;
}

/* Texture Details Native Element Styling */
.details-chevron {
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.texture-details-group.is-open .details-chevron {
    transform: rotate(180deg);
}

.details-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.texture-details-group.is-open .details-content {
    grid-template-rows: 1fr;
}

.details-content-inner {
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.texture-details-group.is-open .details-content-inner {
    opacity: 1;
}

/* Button Group - 3 Buttons Layout */
.button-group {
    display: flex;
    gap: 8px;
    margin-bottom: 0px;
    /* No margin below buttons */
    align-items: center;
}

.section-header-row {
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    /* Minimized space between header and controls */
    position: relative;
}

/* Specific override for h2 inside the flex row to prevent misalignment */
.section-header-row h2 {
    margin-bottom: 0;
}

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

.help-icon {
    width: 24px;
    height: 24px;
    border: 1px solid var(--text-muted);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: help;
    transition: all 0.3s;
}

.help-icon:hover {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    background: rgba(33, 150, 243, 0.1);
}

.help-tooltip {
    position: absolute;
    top: 50px;
    /* Below header */
    right: 0;
    width: 280px;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid #444;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.help-icon:hover+.help-tooltip,
.help-tooltip:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.help-tooltip h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1rem;
    color: var(--accent-blue);
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
}

.tooltip-steps div {
    font-size: 0.85rem;
    color: #ccc;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.t-num {
    background: #333;
    color: var(--accent-blue);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    font-weight: bold;
}

.fmt {
    color: #888;
    font-size: 0.75rem;
    margin-left: 4px;
}

/* Grid Layout */
.grid-control {
    display: grid;
    grid-template-columns: 100px 1fr 60px;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
    position: relative;
}

.grid-control label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.grid-control span {
    font-size: 0.85rem;
    text-align: right;
    font-family: monospace;
}

/* Inputs */
input[type="range"] {
    width: 100%;
    cursor: pointer;
    accent-color: var(--accent-blue);
}

/* GitHub Button Removed */

/* Uiverse Buttons & Loading States */
.uiverse-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 10px 20px;
    background: var(--accent-blue);
    color: white;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-size: 0.9rem;
    width: 100%;
    text-align: center;
    position: relative;
    overflow: hidden;
    min-height: 42px;
    /* Ensure consistency */
}

.uiverse-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

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

.uiverse-btn:disabled {
    background: #555 !important;
    color: #aaa !important;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Button Group - 3 Buttons Layout */
.button-group {
    display: flex;
    gap: 8px;
    margin-bottom: 5px;
    /* Further reduced from 10px */
    align-items: center;
}

.button-group>* {
    flex: 1;
    height: 38px !important;
    /* Slightly more compact height */
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    padding: 0 4px;
    font-size: 0.8rem;
}

/* Ensure secondary buttons look correct */
.uiverse-btn.secondary {
    background: #444;
}

.uiverse-btn.secondary:hover {
    background: #555;
    box-shadow: 0 44px 12px rgba(0, 0, 0, 0.3);
}

.uiverse-btn.secondary {
    background: #444;
}

.uiverse-btn.secondary:hover {
    background: #555;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.uiverse-btn.btn-sm {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.uiverse-btn.warning {
    background: #FF9800;
}

.uiverse-btn.warning:hover {
    background: #F57C00;
}

.uiverse-btn.danger {
    background: #f44336;
}

.uiverse-btn.danger:hover {
    background: #d32f2f;
}

/* Loading Progress Bar Overlay */
.progress-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background-color: var(--success-green);
    /* Checkmark Green or Progress Color */
    width: 0%;
    transition: width 0.2s ease;
    z-index: 10;
}

/* Success State */
.uiverse-btn.success {
    background-color: var(--success-green);
    pointer-events: none;
    /* Prevent double click while showing success */
}

.uiverse-btn span {
    position: relative;
    z-index: 5;
    transition: opacity 0.3s;
}

/* Texture Preview on Button */
.uiverse-btn.has-preview {
    background-size: cover !important;
    background-position: center !important;
    color: transparent !important;
    /* Hide text */
    text-shadow: none;
}

/* Galahhad Switch */
.galahhad-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-direction: row-reverse;
}

/* From Uiverse.io by RaspberryBee */
/* The switch - the box around the slider */
.switch {
    font-size: 10.9px;
    position: relative;
    display: inline-block;
    width: 3.5em;
    height: 2em;
    vertical-align: middle;
}

/* Processing State */
.uiverse-btn.processing {
    pointer-events: none;
    background: repeating-linear-gradient(45deg,
            #FF9800,
            #FF9800 10px,
            #F57C00 10px,
            #F57C00 20px);
    animation: stripe-move 1s linear infinite;
    cursor: wait !important;
    opacity: 0.9;
}

.uiverse-btn.processing:disabled {
    animation: none !important;
    background: #555 !important;
    opacity: 1 !important;
    cursor: not-allowed !important;
}



@keyframes stripe-move {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 28px 0;
        /* Match pattern width approx */
    }
}

/* ViewCube Container */
.view-cube-container {
    position: absolute;
    top: 25px; /* Added some top margin to make room for the home button */
    right: 20px;
    width: 120px;
    height: 120px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* ViewCube Home Button */
.view-cube-home-btn {
    position: absolute;
    top: -10px;
    left: 10px;
    width: 22px;
    height: 22px;
    background: var(--toggle-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px;
    z-index: 101;
    transition: all 0.2s;
    opacity: 0.8;
}

.view-cube-home-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    opacity: 1;
}

.view-cube-home-btn svg {
    width: 100%;
    height: 100%;
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgb(182, 182, 182);
    transition: .4s;
    border-radius: 6.4px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 1.4em;
    width: 1.4em;
    border-radius: 5.1px;
    left: 0.3em;
    bottom: 0.3em;
    transform: rotate(270deg);
    background-color: rgb(255, 255, 255);
    transition: .4s;
}

.switch input:checked+.slider {
    background-color: #21cc4c;
}

.switch input:focus+.slider {
    box-shadow: 0 0 1px #2196F3;
}

.switch input:checked+.slider:before {
    transform: translateX(1.5em);
}

.label-text {
    font-size: 0.85rem;
}

/* Tooltips */
.tooltip-container {
    position: relative;
}

.tooltip {
    visibility: hidden;
    width: 250px;
    background-color: rgba(20, 20, 20, 1);
    /* Changed to fully opaque */
    backdrop-filter: blur(10px);
    /* Added blur for better coverage */
    color: #fff;
    text-align: left;
    border-radius: 4px;
    padding: 8px 12px;
    position: absolute;
    z-index: 1000;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    opacity: 0;
    transition: opacity 0.3s;
    border: 1px solid #444;
    font-size: 0.8rem;
    pointer-events: none;
    white-space: normal;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.tooltip-container:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

/* Main Canvas */
main {
    flex: 1;
    position: relative;
    background-color: var(--bg-dark);
    /* Fixed: Use variable instead of #000 */
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
}

.warning-text {
    color: #f44336;
    font-size: 0.8rem;
    margin-top: 5px;
    font-weight: bold;
}

/* Modern Select Styling */
.modern-select {
    width: 100%;
    padding: 10px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background-image: url('data:image/svg+xml;utf8,<svg width="12" height="8" viewBox="0 0 12 8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1.5L6 6.5L11 1.5" stroke="%23A0A0A0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 8px;
}

[data-theme="light"] .modern-select {
    background-color: rgba(0, 0, 0, 0.05);
}

.modern-select:hover {
    border-color: var(--accent-blue);
    background-color: rgba(33, 150, 243, 0.05);
}

.modern-select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.modern-select option {
    background-color: var(--bg-panel);
    color: var(--text-main);
}

/* Global Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    /* Dark semi-transparent background */
    backdrop-filter: blur(5px);
    z-index: 9999;
    /* Highest priority */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

/* From Uiverse.io by AqFox - 3D Spinner */
.spinner {
    width: 44px;
    height: 44px;
    animation: spinner-y0fdc1 2s infinite ease;
    transform-style: preserve-3d;
    margin-bottom: 20px;
    position: relative;
    top: 30px;
}

.spinner>div {
    background-color: rgba(0, 77, 255, 0.2);
    height: 100%;
    position: absolute;
    width: 100%;
    border: 2px solid #004dff;
}

.spinner div:nth-of-type(1) {
    transform: translateZ(-22px) rotateY(180deg);
}

.spinner div:nth-of-type(2) {
    transform: rotateY(-270deg) translateX(50%);
    transform-origin: top right;
}

.spinner div:nth-of-type(3) {
    transform: rotateY(270deg) translateX(-50%);
    transform-origin: center left;
}

.spinner div:nth-of-type(4) {
    transform: rotateX(90deg) translateY(-50%);
    transform-origin: top center;
}

.spinner div:nth-of-type(5) {
    transform: rotateX(-90deg) translateY(50%);
    transform-origin: bottom center;
}

.spinner div:nth-of-type(6) {
    transform: translateZ(22px);
}

@keyframes spinner-y0fdc1 {
    0% {
        transform: rotate(45deg) rotateX(-25deg) rotateY(25deg);
    }

    50% {
        transform: rotate(45deg) rotateX(-385deg) rotateY(25deg);
    }

    100% {
        transform: rotate(45deg) rotateX(-385deg) rotateY(385deg);
    }
}

/* Pulsing Text Animation */
@keyframes pulseText {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

/* Status Animation Container */
/* Status Animation Container */
.status-container {
    height: 80px;
    /* Increased to prevent cutoff */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    margin-top: 15px;
    width: 100%;
}

.status-line {
    position: absolute;
    width: 100%;
    text-align: center;
    transition: all 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform, opacity;
}

/* Base States */
.status-line.current {
    top: 50%;
    transform: translateY(-50%) scale(1);
    font-size: 1.2rem;
    font-weight: 500;
    color: white;
    opacity: 1;
    z-index: 2;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: baseline;
    gap: 2px;
}

.status-line.next {
    top: 50%;
    transform: translateY(120%) scale(0.85);
    /* Slightly lower to differentiate */
    font-size: 0.95rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.5);
    opacity: 0.6;
    z-index: 1;
}

/* Animated Dots (Opacity based for performance) */
.status-line::after {
    content: none !important;
    display: none !important;
}

/* Animation Classes - High Specificity */
.status-line.slide-out-up {
    transform: translateY(-250%) scale(0.9) !important;
    opacity: 0 !important;
}

.status-line.slide-in-up {
    transform: translateY(-50%) scale(1) !important;
    /* Becomes Current */
    font-size: 1.2rem;
    color: white !important;
    opacity: 1 !important;
}

.status-text-wrapper {
    position: relative;
    display: inline-block;
}

.loading-dots {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    width: auto;
    text-align: left;
    height: auto;
    margin-top: 0;
    margin-left: 4px;
    white-space: nowrap;
}

.loading-dots span {
    opacity: 0;
    animation: dotFade 1.5s infinite;
    display: inline-block;
}

.loading-dots span:nth-child(1) {
    animation-delay: 0.0s;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.5s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 1.0s;
}

@keyframes dotFade {
    0% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* Remove old pseudo-element dots */
.status-line::after {
    display: none;
}

/* status-text class removed as it is merged into loading-text */

.warning-subtext {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #FF9800;
    /* Orange warning color */
    font-weight: 400;
    opacity: 0.9;
}

/* Progress Bar */
/* Progress Bar - Updated Indeterminate */
.progress-container {
    width: 300px;
    height: 6px;
    /* Keeping original size */
    background-color: #47a7ff44;
    /* New bg color */
    border-radius: 8px;
    /* New radius */
    margin-top: 15px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    width: 0%;
    /* Start at 0% for JS control */
    height: 100%;
    background-color: #47a7ff;
    /* New color */
    border-radius: 8px;
    /* transition controlled by JS */
    transform-origin: left;
    box-shadow: none;
    /* Remove old shadow */
}

/* Welcome instruction Overlay - Modernized */
.welcome-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    /* Glassmorphism */
    background: rgba(30, 30, 30, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 40px 60px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);

    pointer-events: none;
    /* Let clicks pass through */
    transition: opacity 0.8s ease, transform 0.8s ease;
    z-index: 10;
}

/* Light Theme Overlay support */
[data-theme="light"] .welcome-overlay {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .welcome-overlay h1,
[data-theme="light"] .welcome-overlay p,
[data-theme="light"] .step-item,
[data-theme="light"] .step-text,
[data-theme="light"] .ctrl-grid {
    color: #1a1a1a;
    /* Dark text for light mode */
}

/* --- Mode Switch (Triplanar/Spherical) --- */
.mode-switch {
    --_switch-bg-clr: #70a9c5;
    --_switch-padding: 4px;
    --_slider-bg-clr: rgba(12, 74, 110, 0.65);
    --_slider-bg-clr-on: rgba(12, 74, 110, 1);
    --_slider-txt-clr: #ffffff;
    --_label-padding: 1rem 2rem;
    --_switch-easing: cubic-bezier(0.47, 1.64, 0.41, 0.8);
    color: white;
    width: 100%;
    position: relative;
    border-radius: 6px;
    cursor: pointer;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    isolation: isolate;
    margin: 0;
    user-select: none;
}

.mode-switch input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.mode-switch>span {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    height: 100%;
    padding: 10px 0;
    margin: 0;
    line-height: 1;
    transition: opacity 300ms ease-in-out 150ms;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 2;
}

.mode-switch::before,
.mode-switch::after {
    content: "";
    position: absolute;
    border-radius: inherit;
    transition: inset 150ms ease-in-out;
}

/* switch slider */
.mode-switch::before {
    background-color: var(--_slider-bg-clr);
    inset: var(--_switch-padding) 50% var(--_switch-padding) var(--_switch-padding);
    transition:
        inset 500ms var(--_switch-easing),
        background-color 500ms ease-in-out;
    z-index: -1;
    box-shadow:
        inset 0 1px 1px rgba(0, 0, 0, 0.3),
        0 1px rgba(255, 255, 255, 0.3);
}

/* switch bg color */
.mode-switch::after {
    background-color: var(--_switch-bg-clr);
    inset: 0;
    z-index: -2;
}

/* switch hover & focus */
.mode-switch:focus-within::after {
    inset: -0.25rem;
}

.mode-switch:has(input:checked):hover>span:first-of-type,
.mode-switch:has(input:not(:checked)):hover>span:last-of-type {
    opacity: 1;
    transition-delay: 0ms;
    transition-duration: 100ms;
}

/* switch hover */
.mode-switch:has(input:checked):hover::before {
    inset: var(--_switch-padding) var(--_switch-padding) var(--_switch-padding) 45%;
}

.mode-switch:has(input:not(:checked)):hover::before {
    inset: var(--_switch-padding) 45% var(--_switch-padding) var(--_switch-padding);
}

/* checked - move slider to right */
.mode-switch:has(input:checked)::before {
    background-color: var(--_slider-bg-clr-on);
    inset: var(--_switch-padding) var(--_switch-padding) var(--_switch-padding) 50%;
}

/* checked - set opacity */
.mode-switch>span:last-of-type,
.mode-switch>input:checked+span:first-of-type {
    opacity: 0.75;
}

.mode-switch>input:checked~span:last-of-type {
    opacity: 1;
}

[data-theme="light"] .key {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.welcome-overlay h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-main);
    letter-spacing: -1px;
}

.welcome-overlay p {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.welcome-overlay.fade-out {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    /* Scale down slightly inward */
}

.arrow-hint {
    font-size: 3rem;
    margin-top: 20px;
    color: var(--accent-blue);
    animation: bounceLeft 2s infinite;
    display: inline-block;
}

@keyframes bounceLeft {

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

    50% {
        transform: translateX(-10px);
    }
}

/* Step List Styles */
.steps-list {
    text-align: left;
    margin: 30px auto 10px auto;
    display: inline-block;
    border-left: 2px solid var(--accent-blue);
    padding-left: 20px;
}

.step-item {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
}

.step-num {
    font-weight: bold;
    color: var(--accent-blue);
    background: rgba(33, 150, 243, 0.1);
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    font-size: 0.9rem;
}

.step-text {
    color: var(--text-main);
}

.arrow-hint {
    font-size: 1.5rem;
    font-weight: 500;
}

/* Tooltip Controls */
/* Tooltip Controls */
.tooltip-controls {
    margin-top: 10px;
    font-size: 0.8rem;
    color: #ccc;
    display: grid;
    /* Two columns: Label (Fixed width) | Value (align right) */
    grid-template-columns: 80px 1fr;
    gap: 5px 10px;
    align-items: center;
}

.tooltip-controls div {
    display: contents;
    /* Flatten children so they participate in the grid */
}

/* Specific styling for the cells */
.tooltip-controls strong span {
    display: inline-block;
    width: 20px;
    /* Fixed width for icon alignment */
    text-align: center;
}

.tooltip-controls strong {
    font-weight: 600;
    color: white;
    /* Changed from accent-blue as requested */
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.tooltip-controls span {
    /* The action text (right column) */
    text-align: right;
    color: #bbb;
}

/* Overlay Controls */
.overlay-controls {
    margin-top: 0px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.overlay-controls h3 {
    font-size: 1.1rem;
    color: var(--accent-blue);
    margin-bottom: 15px;
}

.control-row {
    margin-bottom: 10px;
    /* Added spacing to separate from buttons */
}

.ctrl-grid {
    display: flex;
    justify-content: center;
    gap: 30px;
    color: var(--text-muted);
}

.ctrl-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.9rem;
}

/* Scrolling Ticker */
.ticker-wrap {
    position: absolute;
    bottom: 0;
    width: 100%;
    overflow: hidden;
    height: 40px;
    background-color: var(--bg-ticker);
    /* Use dedicated ticker variable */
    backdrop-filter: blur(5px);
    border-top: 1px solid var(--border-color);
    box-sizing: border-box;
    z-index: 5;
    /* Above canvas, below overlays */
    display: flex;
    align-items: center;
}

.ticker {
    display: flex;
    /* Speed multiplied by 1.25 (80s / 1.25 = 64s) */
    animation: ticker 64s linear infinite;
    white-space: nowrap;
}

.ticker-item {
    display: inline-block;
    padding: 0 50px;
    font-size: 0.9rem;
    color: var(--text-main);
    /* Adapt text color */
}

.ticker-item strong {
    color: var(--accent-blue);
}

@keyframes ticker {
    0% {
        transform: translate3d(0, 0, 0);
    }

    100% {
        transform: translate3d(-50%, 0, 0);
    }
}

/* Warning Toast */
.warning-toast {
    color: #ff9800;
    font-size: 0.9rem;
    font-weight: bold;
    text-align: center;
    margin-top: 10px;
    background: rgba(255, 152, 0, 0.1);
    border: 1px solid #ff9800;
    padding: 8px;
    border-radius: 4px;

    /* Animation defaults setup */
    opacity: 0;
    display: none;
    /* Controlled by JS, but good default */
}

.warning-toast.show {
    display: block !important;
    opacity: 1;
    animation: flashIn 0.4s ease-out forwards;
}

.warning-toast.hide {
    display: block;
    /* Ensure it stays visible for the animation */
    animation: fadeOut 0.5s ease-in forwards;
    pointer-events: none;
}

@keyframes flashIn {
    0% {
        opacity: 0;
        transform: translateY(-5px) scale(0.9);
        background-color: white;
        box-shadow: 0 0 20px white;
        border-color: white;
        color: #333;
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        /* Revert to original styles defined in class */
        background-color: rgba(255, 152, 0, 0.1);
        box-shadow: none;
        border-color: #ff9800;
        color: #ff9800;
    }
}

@keyframes fadeOut {
    0% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(5px);
    }
}

/* --- Preset Popover --- */
.preset-popover {
    position: absolute;
    left: 105%;
    /* Position to the right of the button */
    top: -50px;
    width: 220px;
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 1000;
}

[data-theme="light"] .preset-popover {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.preset-popover.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
    /* Enable clicks when visible */
}

.preset-header {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.preset-item {
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    aspect-ratio: 1;
    border: 1px solid transparent;
    transition: transform 0.2s;
}

.preset-item:hover {
    transform: scale(1.05);
    border-color: var(--accent-blue);
    z-index: 1;
}

.preset-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.preset-item span {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.7rem;
    padding: 2px 4px;
    text-align: center;
    backdrop-filter: blur(2px);
}

/* --- Lock Selection Switch (Namespaced) --- */
.lock-switch {
    height: 24px;
    display: block;
    position: relative;
    cursor: pointer;
}

.lock-switch input {
    display: none;
}

.lock-switch input+span {
    padding-left: 50px;
    min-height: 24px;
    line-height: 24px;
    display: block;
    color: #99a3ba;
    position: relative;
    /* vertical-align: middle; Removed as it is ignored on block elements */
    white-space: nowrap;
    transition: color 0.3s ease;
}

.lock-switch input+span:before,
.lock-switch input+span:after {
    content: "";
    display: block;
    position: absolute;
    border-radius: 12px;
}

.lock-switch input+span:before {
    top: 0;
    left: 0;
    width: 42px;
    height: 24px;
    background: #e4ecfa;
    transition: all 0.3s ease;
}

.lock-switch input+span:after {
    width: 18px;
    height: 18px;
    background: #fff;
    top: 3px;
    left: 3px;
    box-shadow: 0 1px 3px rgba(18, 22, 33, 0.1);
    transition: all 0.45s ease;
}

.lock-switch input+span em {
    width: 8px;
    height: 7px;
    background: #99a3ba;
    position: absolute;
    left: 8px;
    bottom: 7px;
    border-radius: 2px;
    display: block;
    z-index: 1;
    transition: all 0.45s ease;
}

.lock-switch input+span em:before {
    content: "";
    width: 2px;
    height: 2px;
    border-radius: 1px;
    background: #fff;
    position: absolute;
    display: block;
    left: 50%;
    top: 50%;
    margin: -1px 0 0 -1px;
}

.lock-switch input+span em:after {
    content: "";
    display: block;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    border: 1px solid #99a3ba;
    border-bottom: 0;
    width: 6px;
    height: 4px;
    left: 1px;
    bottom: 6px;
    position: absolute;
    z-index: 1;
    transform-origin: 0 100%;
    transition: all 0.45s ease;
    transform: rotate(-35deg) translate(0, 1px);
}

.lock-switch input+span strong {
    display: none;
}

.lock-switch input+span strong:before,
.lock-switch input+span strong:after {
    font-size: 14px;
    font-weight: 500;
    display: block;
    font-family: inherit;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.lock-switch input+span strong:before {
    content: "Unlocked";
    transition: all 0.3s ease 0.2s;
}

.lock-switch input+span strong:after {
    content: "Locked";
    opacity: 0;
    visibility: hidden;
    position: absolute;
    left: 0;
    top: 0;
    color: #02923c;
    transition: all 0.3s ease;
    transform: translate(2px, 0);
}

.lock-switch input:checked+span:before {
    background: #eae7e7;
}

.lock-switch input:checked+span:after {
    background: #fff;
    transform: translate(18px, 0);
}

.lock-switch input:checked+span em {
    transform: translate(18px, 0);
    background: #02923c;
}

.lock-switch input:checked+span em:after {
    border-color: #02923c;
    transform: rotate(0deg) translate(0, 0);
}

.lock-switch input:checked+span strong:before {
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    transform: translate(-2px, 0);
}

.lock-switch input:checked+span strong:after {
    opacity: 1;
    visibility: visible;
    transform: translate(0, 0);
    transition: all 0.3s ease 0.2s;
}

.lock-switch :before,
.lock-switch :after {
    box-sizing: border-box;
}

/* --- Modern Range Slider --- */
.slider-row-horizontal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding-top: 0;
    /* Total gap determined by header margin (10px) */
    padding-bottom: 5px;
    margin-top: 0;
    position: relative;
    /* Ensure tooltip positioning works contextually */
}

/* Fix: Move tooltip below the slider to avoid blocking the bubble */
.slider-row-horizontal .tooltip {
    bottom: auto;
    top: 100%;
    margin-bottom: 0;
    margin-top: 8px;
    z-index: 100;
    /* Lower than bubble if needed, but spacing should fix it */
}

.slider-row-horizontal label {
    white-space: nowrap;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.range-slider-wrapper {
    position: relative;
    width: 100%;
    margin: 0;
    flex: 1;
    display: flex;
    /* Helps align input internally */
    align-items: center;
}

/* Modern Range Slider (Selection - Thick Style) */
.modern-range {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 16px;
    /* Thicker bar */
    background: linear-gradient(to right, #4a90e2 0%, #4a90e2 var(--val-percent, 30%), #e0e0e0 var(--val-percent, 30%), #e0e0e0 100%);
    border-radius: 8px;
    /* match half height */
    outline: none;
    transition: background 0.1s;
    margin: 0;
    cursor: pointer;
}

/* Slider Thumb (Thick Style) */
.modern-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    /* Same as height */
    height: 16px;
    border-radius: 50%;
    background: #fff;
    /* White thumb for contrast inside blue/gray */
    border: 2px solid #4a90e2;
    /* Blue ring */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.1s ease;
    margin-top: 0;
    /* Centered since heights match */
}

.modern-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.modern-range::-webkit-slider-thumb:active {
    transform: scale(0.95);
}

/* Texture Range Slider (HeroUI Style) */
.texture-range {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    /* HeroUI: Balanced Track */
    background-color: #3f3f46;
    /* Empty Dark Gray */
    background-image: linear-gradient(#338ef7, #338ef7);
    /* Filled Blue */
    background-size: calc(8px + (100% - 16px) * var(--val-decimal, 0)) 100%;
    /* Exact center math: ThumbRadius + TravelDist * Progress */
    background-repeat: no-repeat;
    border-radius: 3px;
    outline: none;
    margin: 0;
    cursor: pointer;
    vertical-align: middle;
}

/* Texture Slider Thumb */
.texture-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #000000;
    /* Black Thumb */
    border: 2px solid #338ef7;
    /* Blue Ring */
    /* box-shadow: 0 0 0 4px rgba(0, 0, 0, 1); REMOVED - Caused conflict */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    cursor: grab;
    transition: transform 0.1s ease, border-color 0.1s ease;
    margin-top: -1px;
    /* Adjusted to -1px to center thumb vertically */
    box-sizing: border-box;
}

.texture-range::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.modern-range::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.modern-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #4a90e2;
    cursor: pointer;
}

/* Value Bubble */
.value-bubble {
    position: absolute;
    top: -35px;
    left: var(--val-percent, 30%);
    /* Dynamic Position */
    transform: translateX(-50%);
    background: #1a1a1a;
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: bold;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, top 0.2s;
}

.value-bubble::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px 5px 0;
    border-style: solid;
    border-color: #1a1a1a transparent transparent transparent;
}

/* Show bubble on hover/active */
.range-slider-wrapper:hover .value-bubble,
.modern-range:active+.value-bubble,
.modern-range:focus+.value-bubble {
    opacity: 1;
    top: -40px;
    /* Slight lift */
}


/* --- New Theme Button Styles (Uiverse Type-Delta) --- */
/* --- New Theme Button Styles (Uiverse Type-Delta) --- */
#themeToggle {
    padding: 0 !important;
    overflow: hidden;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    display: flex;
    /* Ensure centering */
    align-items: center;
    justify-content: center;
}

/* From Uiverse.io by Type-Delta - Adapted */
.themeToggle {
    color: #bbb;
    width: 100%;
    /* Fit container */
    height: 100%;
}

.st-sunMoonThemeToggleBtn {
    /* position: relative; REMOVED to keep position:absolute from .theme-toggle */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Removed width/height 100% to prevent overriding 34px from .theme-toggle */
}

.st-sunMoonThemeToggleBtn .themeToggleInput {
    opacity: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    /* Clickable */
    cursor: pointer;
}

.st-sunMoonThemeToggleBtn svg {
    width: 100%;
    /* Fit 34px */
    height: 100%;
    transform: rotate(-45deg);
}

.st-sunMoonThemeToggleBtn svg .sunMoon {
    transform-origin: center center;
    transition: inherit;
    transform: scale(1);
}

.st-sunMoonThemeToggleBtn svg .sunRay {
    transform-origin: center center;
    transform: scale(0);
}

.st-sunMoonThemeToggleBtn svg mask>circle {
    transition: transform 0.64s cubic-bezier(0.41, 0.64, 0.32, 1.575);
    transform: translate(0px, 0px);
}

.st-sunMoonThemeToggleBtn svg .sunRay2 {
    animation-delay: 0.05s !important;
}

.st-sunMoonThemeToggleBtn svg .sunRay3 {
    animation-delay: 0.1s !important;
}

.st-sunMoonThemeToggleBtn svg .sunRay4 {
    animation-delay: 0.17s !important;
}

.st-sunMoonThemeToggleBtn svg .sunRay5 {
    animation-delay: 0.25s !important;
}

.st-sunMoonThemeToggleBtn svg .sunRay6 {
    /* Added 6th ray support */
    animation-delay: 0.29s !important;
}

/* Checked = Sun (Light Mode) */
.st-sunMoonThemeToggleBtn .themeToggleInput:checked+svg {
    transform: rotate(90deg);
}

.st-sunMoonThemeToggleBtn .themeToggleInput:checked+svg mask>circle {
    transform: translate(16px, -3px);
}

.st-sunMoonThemeToggleBtn .themeToggleInput:checked+svg .sunMoon {
    transform: scale(0.55);
}

.st-sunMoonThemeToggleBtn .themeToggleInput:checked+svg .sunRay {
    animation: showRay1832 0.4s ease 0s 1 forwards;
}

@keyframes showRay1832 {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}