* {
    font-family: "Montserrat";
    box-sizing: border-box;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
span,
div,
button,
ul,
li,
img {
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    padding: 0;
    margin: 0;
    overflow: hidden;
    background-color: #090D14;
    color: #d9d9d9;
    font-size: 16px;
}

button {
    cursor: pointer;
    border: none;
    background-color: red;
    color: #d9d9d9;
}

label,
span {
    color: #d9d9d9;
}

input[type="range"] {
    cursor: pointer;
    background-color: #090D14;
    /* Allow the range to flex and yield space to the label when needed */
    flex: 1 1 140px;
    height: 6px;
    background: #090D14;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 20px;
    background: #d9d9d9;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #333333;
}

input[type="range"]::-moz-range-thumb {
    width: 10px;
    height: 20px;
    background: #d9d9d9;
    border-radius: 5px;
    cursor: pointer;
    border: none;
    transition: background 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    background: #333333;
}

.hidden {
    display: none !important;
}

.separator-10 {
    height: 10px;
    width: 100%;
}

.app-header {
    position: fixed;
    margin: 0;
    padding: 0;
    width: 100%;
    top: 0;
    background-color: #090D14;
    display: flex;
    align-items: center;
    height: 50px;
}

.header-content {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    width: 20%;
    padding-left: 20px;
    padding-right: 20px;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.logo {
    width: 40px;
    height: 40px;
}

.title {
    color: #d9d9d9;
    font-size: 1.5rem;
    font-weight: 400;
    display: flex;
    align-items: center;
}

.main-content {
    display: flex;
    width: 100%;
    margin-top: 0;
    padding-top: 0;
    height: 100%;
    overflow: hidden;
}

.left-bar {
    display: flex;
    width: 18vw;
    height: 100%;
    left: 0;
    padding-top: 50px;
    border-top-right-radius: 7px;
    overflow: hidden;
}

.left-tools {
    width: 4.5vw;
    flex-shrink: 0;
    left: 0;
    display: flex;
    justify-content: flex-start;
    padding-top: 20px;
    flex-direction: column;
    background-color: #080808;
}

.left-ws {
    flex: 1;
    right: inherit;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 10px 10px 20px;
    background-color: #080808;
    /* border: solid 1px #333333; */
}

.left-ws-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Hide scrollbar for the parent and EVERY nested element within it */
.left-ws-body, 
.left-ws-body * {
  scrollbar-width: none;               /* Firefox */
  -ms-overflow-style: none;            /* IE/Edge */
}

.left-ws-body::-webkit-scrollbar,
.left-ws-body *::-webkit-scrollbar {
  display: none;                       /* Chrome/Safari */
}

.patients-list {
    color: #333333;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    gap: 20px;
    margin-top: 10px;
}

.patient-item {
    position: relative;
    width: 100%;
    /* Set a fixed height or min-height, and prevent shrinking */
    min-height: 80px;
    flex-shrink: 0;
    border-radius: 15px;
    overflow: hidden;
}

.patient-item img {
    transition: filter 0.2s, opacity 0.2s;
}

.patient-item:hover {
    background-color: #232323;
}

.patient-item:hover img {
    filter: brightness(1.5);
    opacity: 1;
}

.patient-item img {
    width: 100%;
    height: 100%;
    display: block;
    margin: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 10px;
    cursor: pointer;
    padding: 0;
}

.patient-name {
    position: absolute;
    left: 0;
    bottom: 0;
    font-size: 0.85rem;
    text-align: left;
    padding: 5px 5px 5px 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 0 10px 0 0;
    background-color: #080808;
}

.tool-button {
    font-size: 0.85rem;
    width: calc(100% - 10px);
    padding: 5px;
    margin: 5px;
    border: none;
    border-radius: 10px;
    background-color: transparent;
    color: #d9d9d9;
    cursor: pointer;
    text-align: center;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tool-icon {
    width: 25px;
    height: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tool-button:hover {
    background-color: #1a1a1a;
}

.tool-button.hidden {
    display: none;
}

#fusion-icon {
    width: 40px;
    height: 40px;
}

.left-ws-topbar {
    width: 100%;
    height: 70px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
}

.left-ws-return {
    width: 40px;
    height: 40px;
    margin: 0;
    background-color: transparent;
    border-radius: 10px;
    display: flex;
    text-align: center;
    align-items: center;
    justify-content: center;
}

.left-ws-return-icon {
    width: 25px;
    height: 25px;
}

.left-ws-return:hover {
    background-color: #1a1a1a;
}

.left-ws-title {
    font-size: 1.2rem;
    text-align: center;
    color: #d9d9d9;
}

/* Hide return btn when in zenith (does nothing there) */
body:has(#zenith-tools:not(.hidden)) .left-ws-return { display: none; }

/* Collapse button — always-right in topbar */
.left-ws-collapse-btn {
    width: 30px;
    height: 30px;
    margin-left: auto;
    margin-right: 0px;
    background: transparent;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.left-ws-collapse-btn:hover { background: #1a1a1a; }
.left-ws-collapse-btn .left-ws-return-icon { width: 18px; height: 18px; opacity: 0.5; }
.left-ws-collapse-btn:hover .left-ws-return-icon { opacity: 0.9; }

/* Collapsed panel state */
.left-ws--collapsed { display: none !important; }

.upload-controls {
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #333333;
    background: #d9d9d9;
    border-radius: 10px;
    backdrop-filter: blur(2px);
    width: 100%;
    height: 80px;
    overflow: hidden;
}

.upload-label {
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 400;
    height: 30px;
}

.upload-buttons {
    display: flex;
    width: 100%;
    height: 70%;
}

.upload-button {
    padding: 10px;
    background: transparent;
    color: #333333;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    height: 100%;
    transition: background 0.2s ease, transform 0.1s ease;
}

.upload-button:hover {
    background: #ffffff;
}

.upload-button:active {
    transform: translateY(1px);
}

.hidden-file-input {
    display: none;
}

.viewer-container {
    z-index: 10;
    width: 80vw;
    height: 100%;
    border-radius: 15px;
    background-color: #000000;
    position: relative;
    border-left: solid 1px #333333;
    display: grid;
    grid-template-columns: 60% 40%;
    grid-template-rows: repeat(3, 1fr);
    grid-template-areas:
        "view3d view1"
        "view3d view2"
        "view3d view3";
    overflow: hidden;
    outline: none;
}

.view1-container canvas,
.view2-container canvas,
.view3-container canvas,
.view4-container canvas,
.view5-container canvas,
.view3d-container canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: auto;
    /* cursor: pointer; */
    outline: none;
    z-index: 30;
}

.view1-container,
.view2-container,
.view3-container,
.view4-container,
.view5-container,
.view3d-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: transparent;
    z-index: 20;
    position: relative;
    border-left: #090D14 2px solid;
    /* cursor: pointer; */
    outline: none;
}

.view1-container.hidden,
.view2-container.hidden,
.view3-container.hidden,
.view4-container.hidden,
.view5-container.hidden,
.view3d-container.hidden {
    display: none;
}

.view3d-container {
    grid-area: view3d;
}

.view1-container {
    grid-area: view1;
}

.view2-container {
    grid-area: view2;
}

.view3-container {
    grid-area: view3;
}

.view4-container {
    grid-area: view4;
}

.view5-container {
    grid-area: view5;
}

.view4-container,
.view5-container {
    display: none;
}

.controls-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: left;
    margin-top: 5px;
    margin-left: 5%;
    pointer-events: none;
    gap: 8px;
    z-index: 1000;
}

.view-button {
    width: 30px;
    height: 30px;
    z-index: 1000;
    border-radius: 6px;
    justify-content: center;
    display: flex;
    align-items: center;
    background-color: transparent;
    pointer-events: auto;
}

.view-button img {
    width: 15px;
    height: 15px;
}

.view-button:hover {
    background-color: #333333;
}

.view-orientation-label {
    z-index: 1000;
    border-radius: 6px;
    padding: 4px 8px;
    color: #d9d9d9;
    font-size: 0.85rem;
    cursor: pointer;
    pointer-events: auto;
    font-weight: 500;
    background: transparent;
    backdrop-filter: blur(4px);
}


.orientation-presets-controls {
    position: absolute;
    left: 20px;
    top: 50px;
    /* transform: translateY(-50%); */
    margin-top: 8px;
    width: 8%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    z-index: 1000;
    height: 40%;
    overflow-y: auto;
    /* Enable vertical scrolling if content exceeds max height */
    gap: 0;
}

.preset-button {
    flex: 1 1 0;
    width: 100%;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    pointer-events: auto;
    min-height: 0;
}

.preset-button img {
    width: 90%;
    height: 90%;
    object-fit: contain;
    aspect-ratio: 1 / 1;
}

.preset-button:hover {
    background-color: #333333;
}

.iso-slider-container {
    position: absolute;
    bottom: 3%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #333333;
    border-radius: 10px;
    padding: 10px;
    min-width: 260px;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.iso-slider-container.hidden {
    display: none;
}

.iso-slider-container label {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d9d9d9;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    /* prevent label text from wrapping */
    flex: 0 0 auto;
    /* don't let the label shrink below its content width */
}

.iso-slider-container #iso-value {
    color: #d9d9d9;
    font-weight: 600;
    margin-left: 6px;
}

.iso-slider-container input[type="range"] {
    /* Allow the range to flex and yield space to the label when needed */
    flex: 1 1 140px;
    min-width: 120px;
    height: 6px;
    background: #090D14;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.iso-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 25px;
    background: #d9d9d9;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.iso-slider-container input[type="range"]::-webkit-slider-thumb:hover {
    background: #d9d9d9;
}

.iso-slider-container input[type="range"]::-moz-range-thumb {
    width: 10px;
    height: 25px;
    background: #3c89ff;
    border-radius: 5px;
    cursor: pointer;
    border: none;
    transition: background 0.2s ease;
}

.iso-slider-container input[type="range"]::-moz-range-thumb:hover {
    background: #3c89ff;
}

/* 3d controls top */
.render-mode-controls {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 100;
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    background: transparent;
    border-radius: 8px;
    padding: 8px;
    pointer-events: auto;
}

.render-mode-controls.hidden {
    display: none;
}

.focus-mode-button {
    border-left: 1px solid #333333;
    padding-left: 12px;
    z-index: 100;
}


/* Show views dropdown */
/* Custom multiselect for show views */
.custom-multiselect {
    position: relative;
    display: inline-block;
    z-index: 1000;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-left: auto;
}

.cm-toggle {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #333333;
    border-radius: 6px;
    padding: 6px 10px;
    color: #d9d9d9;
    font-size: 0.85rem;
    cursor: pointer;
}

.cm-toggle:hover {
    background-color: #333333;
}

.cm-options {
    position: absolute;
    top: 100%;
    right: 0px;
    height: 310px;
    border: 1px solid #333333;
    border-radius: 8px;
    padding: 5px;
    margin-top: 10px;
    min-width: 200px;
    z-index: 1001;
    display: flex;
    overflow: auto;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.cm-list {
    position: absolute;
    top: 10px;
    left: 10px;
    background: transparent;
    padding: 0px;
    min-width: 160px;
    z-index: 1001;
}

.cm-list li {
    list-style: none;
    padding: 6px;
    font-size: 0.8rem;
    pointer-events: auto;
}

.cm-list li:hover {
    background-color: #333333;
    border-radius: 4px;
}

.cm-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #d9d9d9;
}

/* Custom checkbox: change color here. */
.cm-list input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid #333333;
    display: inline-block;
    position: relative;
    background: transparent;
}

.cm-list input[type="checkbox"]:checked {
    background: #0088f1;
    border-color: #0088f1;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px 12px;
}

/* clip opacity change */
.clip-sliders-container {
    position: relative;
    top: 100%;
    width: 120px;
    background: transparent;
    min-width: 100px;
    z-index: 1001;
    display: flex;

}

.slider-label {
    position: relative;
    color: #d9d9d9;
    left: 0px;
    font-size: 0.85rem;
    align-items: left;
    width: 100%;
    margin-bottom: 5px;
    margin-left: 10px;
}

.clip-sliders {
    position: relative;
    left: 10px;
    width: 100px;
    justify-content: left;
    /* align vertically */
    align-items: center;
    background: #333333;
}

.slider-label-number {
    position: relative;
    color: #d9d9d9;
    font-size: 0.85rem;
    align-items: right;
    justify-content: right;
    width: 40px;
}

.cm-options.hidden {
    display: none;
}

/* ensure hidden input doesn't show */
#clip-planes {
    display: none;
}


/* clip-view-trigger inherits base styles from .view-button; only layout tweaks here */
.clip-view-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: fit-content;
    background-color: rgba(0, 0, 0, 0.6);
    border: 1px solid #333333;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.clip-view-select {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.clip-view-label {
    padding-left: 10px;
}

/* Arrow indicator: down when closed, up when open */
.clip-view-arrow {
    width: 0;
    height: 0;
    margin-right: 10px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #d9d9d9;
    /* down arrow by default */
}

.clip-view-select[data-open="true"] .clip-view-arrow {
    border-top: none;
    border-bottom: 6px solid #d9d9d9;
    /* up arrow when open */
}

/* Hide the native select but keep it accessible and functional */
#clip-view-select-dropdown {
    position: absolute;
    inset: 0;
    border: none;
    pointer-events: none;
    background: transparent;
    color: transparent;
}

#clip-view-select-dropdown option {
    background: #090D14;
    color: #d9d9d9;
}

#clip-view-select-dropdown option:hover {
    background: #333333;
    outline: none;
}

#clip-view-select-dropdown option:checked {
    background: #333333;
    color: #d9d9d9;
}

#clip-view-select-dropdown::picker-indicator {
    display: none;
}


/* 3D renderer actors visibility */

.visibility-controls-3d {
    position: absolute;
    z-index: 1000;
    min-width: 100px;
    height: auto;
    bottom: 3%;
    height: fit-content;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: right;
    gap: 8px;
    background: transparent;
    padding: 10px;
    pointer-events: auto;
    border: 1px solid #333333;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.visibility-controls-title {
    color: #d9d9d9;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 5px;
    left: 10px;
    text-align: left;
}

.item-visibility-3d {
    height: 30px;
    margin-top: 5px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

#item-visibility-3d-toggle {
    position: relative;
    height: 100%;
    aspect-ratio: 1 / 1;
    left: 0px;
    align-items: right;
    justify-content: space-between;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

#item-visibility-3d-toggle .item-visibility-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    pointer-events: none;
    background: transparent;
}

#item-visibility-3d-toggle:hover {
    background: #333333;
}

.item-visibility-more {
    margin-left: 6px;
    padding: 5px 8px;
    height: 80%;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid #333333;
    color: #d9d9d9;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.item-visibility-more:hover {
    background: #4f5368;
}

.item-visibility-options {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 6px;
    padding: 10px;
    border: 1px solid #333333;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
}

.item-visibility-options.hidden {
    display: none;
}

#item-visibility-3d-transparency-slider {
    width: 120px;
    height: 6px;
}

.item-visibility-colors {
    display: grid;
    grid-template-columns: repeat(5, 24px);
    gap: 6px;
}

.item-visibility-color {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid #333333;
    cursor: pointer;
    padding: 0;
}

.item-visibility-color:focus-visible,
.item-visibility-color.selected {
    outline: 2px solid #2f6fed;
}

#item-visibility-3d-label {
    position: relative;
    width: max-content;
    color: #d9d9d9;
    font-size: 0.9rem;
    text-align: left;
    left: 0px;
    min-width: 70px;
    margin-right: auto;
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-visibility-3d-transparency-slider.hidden {
    display: none;
}

/* slice view */

.slice-view {
    width: 100%;
    height: 100%;
}

/* Slice offset controls (axial/coronal/sagittal) */


.slice-offset-group {
    position: absolute;
    width: 20px;
    height: 80%;
    z-index: 60;
    background: transparent;
    border-radius: 8px;
    padding: 8px 10px;
    pointer-events: auto;
    min-width: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    right: 5%;
    top: 50%;
    transform: translateY(-50%);
}

.slice-offset-group input[type="range"] {
    -webkit-appearance: none !important;
    appearance: none;
    width: 20px;
    height: 80%;
    background: transparent;
    border-radius: 3px;
    outline: none;
    writing-mode: vertical-rl;
    direction: rtl;
}

/* Custom track using background layers: base track + repeating ticks */
.slice-offset-group input[type="range"] {
    background-image:
        repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.4) 1px, transparent 5px 20%),
        repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.2) 1px, transparent 3px 10%);
    background-repeat: repeat;
    background-position: center center;
    background-size: 8px 100%;
    border-radius: 3px;
}

.slice-offset-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 50px;
    height: 3px;
    background: #aaaaaa;
    border-radius: 3px;
    cursor: pointer;
    border: none;
}

.slice-offset-group input[type="range"]::-webkit-slider-thumb:hover {
    background: #d5d5d5;
}

.slice-offset-group input[type="range"]::-moz-range-thumb {
    width: 40px;
    height: 5px;
    background: #aaaaaa;
    border-radius: 3px;
    cursor: pointer;
    border: none;
}

.slice-offset-group input[type="range"]::-moz-range-thumb:hover {
    background: #d5d5d5;
}

.wl-controls-container {
    position: fixed;
    bottom: 3%;
    right: 3%;
    z-index: 100;
    pointer-events: auto;
}

.wl-toggle-button {
    background: #090D14;
    color: #d9d9d9;
    border: 1px solid #546175;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease;
    font-weight: 500;
}

.wl-toggle-button:hover {
    background: #333333;
}

.wl-sliders {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #545454;
    border-radius: 8px;
    padding: 16px;
    min-width: 280px;
    backdrop-filter: blur(4px);
}

.wl-sliders.hidden {
    display: none;
}

.wl-slider-group {
    margin-bottom: 16px;
}

.wl-slider-group:last-child {
    margin-bottom: 0;
}

.wl-slider-group label {
    display: block;
    color: #d5dce6;
    font-size: 0.85rem;
    margin-bottom: 8px;
    font-weight: 500;
}

.wl-slider-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: #333333;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.wl-slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #3c89ff;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease;
}

.wl-slider-group input[type="range"]::-webkit-slider-thumb:hover {
    background: #5a9eff;
}

.wl-slider-group input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #3c89ff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: background 0.2s ease;
}

.wl-slider-group input[type="range"]::-moz-range-thumb:hover {
    background: #5a9eff;
}

/* progress popup */
.progress-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #545454;
    border-radius: 10px;
    padding: 20px 30px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    gap: 15px;
}

.progress-popup.hidden {
    display: none;
}

/* Rotating spinner animation */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.progress-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(217, 217, 217, 0.2);
    border-top-color: #3c89ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

#progress-message {
    color: #d9d9d9;
    font-size: 0.95rem;
    text-align: center;
}

#settings-button {
    position: relative;
    margin-top: auto;
}

/* ── Section switcher ─────────────────────────────────────────────────────── */

.section-switcher {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 5px;
}

.section-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 100%;
    position: relative;
    padding: 8px 5px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #c8c8c8;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.section-btn .tool-icon {
    width: 22px;
    height: 22px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.section-btn svg.tool-icon { stroke: currentColor; }

.section-btn:hover { background: #1a1a1a; color: #d9d9d9; }
.section-btn:hover .tool-icon { opacity: 0.85; }

.section-btn.active {
    background: rgba(0, 136, 241, 0.1);
    border-color: rgba(0, 136, 241, 0.3);
    color: #0088f1;
}
.section-btn.active .tool-icon { opacity: 1; }

.section-btn--disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.section-divider {
    height: 1px;
    background: #1f1f1f;
    margin: 4px 8px;
}

/* ── Zenith tool active state ─────────────────────────────────────────────── */

#zenith-tools .tool-button.active {
    background: rgba(0, 136, 241, 0.1);
    border: 1px solid rgba(0, 136, 241, 0.3);
    color: #0088f1;
}
#zenith-tools .tool-button.active .tool-icon { opacity: 1; }

.bottom-tool { margin-top: 0 !important; }
#zenith-tools + .bottom-tool,
#imaging-tools + .bottom-tool { margin-top: auto !important; }

/* ── Zenith left workspace ────────────────────────────────────────────────── */

.zenith-info-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
}
.info-label { color: #555; font-weight: 500; }
.info-value  { color: #d9d9d9; font-weight: 600; }

.session-group { display: flex; flex-direction: column; margin-bottom: 8px; }

.session-date-header {
    font-size: 0.72rem;
    font-weight: 600;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 16px 6px;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    border-radius: 8px;
    margin: 2px 6px;
    border: 1px solid transparent;
    transition: background 0.15s;
}
.session-item:hover { background: #1a1a1a; }
.session-item.active {
    background: rgba(0, 136, 241, 0.08);
    border-color: rgba(0, 136, 241, 0.2);
}

.session-play-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #1f1f1f;
    color: #d9d9d9;
    flex-shrink: 0;
    transition: background 0.15s;
}
.session-item:hover .session-play-icon,
.session-item.active .session-play-icon { background: #0088f1; color: #fff; }
.session-play-icon svg { width: 14px; height: 14px; }

.session-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.session-time     { font-size: 0.88rem; font-weight: 600; color: #d9d9d9; }
.session-filename {
    font-size: 0.7rem;
    color: #444;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.sessions-state {
    padding: 24px 16px;
    font-size: 0.82rem;
    color: #555;
    text-align: center;
    line-height: 1.6;
}
.sessions-error { color: #933; }

/* ── Device Cards (Gallery sidebar) ──────────────────────────────────────── */

#zenith-device-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    overflow-y: auto;
}

.device-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.07);
    background: rgba(255,255,255,0.03);
    cursor: pointer;
    transition: background 0.15s, border-color 0.2s, box-shadow 0.2s;
}

.device-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.device-card:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.12);
}

.device-card--active {
    border-color: rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.07);
}

.device-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.device-card-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-card-code {
    font-size: 0.85rem;
    color: #444;
    font-family: monospace;
    letter-spacing: 0.08em;
}

.device-card-label {
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Status dot */
.device-card-status {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.device-card-status--checking {
    background: #555;
    animation: pulse-check 1.2s ease-in-out infinite;
}

.device-card-status--online {
    background: #2ecc71;
    box-shadow: 0 0 0 0 rgba(46,204,113,0.6);
    animation: pulse-online 2s ease-in-out infinite;
}

.device-card-status--offline {
    background: #444;
}

.device-card--online {
    border-color: rgba(46,204,113,0.25);
    box-shadow: 0 0 12px rgba(46,204,113,0.08);
}

.device-card--online:hover,
.device-card--online.device-card--active {
    border-color: rgba(46,204,113,0.45);
    box-shadow: 0 0 18px rgba(46,204,113,0.15);
}

.device-card-label--online  { color: #2ecc71; }
.device-card-label--offline { color: #555; }
.device-card-label--checking { color: #555; }

@keyframes pulse-online {
    0%   { box-shadow: 0 0 0 0 rgba(46,204,113,0.5); }
    70%  { box-shadow: 0 0 0 5px rgba(46,204,113,0); }
    100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); }
}

@keyframes pulse-check {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

/* ── Device card action buttons ─────────────────────────────────────────────*/

.device-card-actions {
    display: flex;
    gap: 6px;
}

.device-card-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 8px;
    border-radius: 7px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    min-height: 30px;
    border: 1px solid;
}

.device-card-btn svg { width: 11px; height: 11px; flex-shrink: 0; }

.device-card-btn--stream {
    background: rgba(0,136,241,0.1);
    border-color: rgba(0,136,241,0.3);
    color: #0088f1;
}
.device-card-btn--stream:hover { background: rgba(0,136,241,0.22); }

.device-card-btn--gallery {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.1);
    color: #888;
}
.device-card-btn--gallery:hover { background: rgba(255,255,255,0.1); color: #ddd; }

/* Disabled tool button (cloud gallery placeholder) */
.tool-button--disabled {
    opacity: 0.4;
}

.coming-soon-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: #1a2a3a;
    color: #4a9edd;
    border: 1px solid #1e4a6e;
    border-radius: 4px;
    padding: 1px 4px;
    line-height: 1.4;
    pointer-events: none;
}

/* ── Zenith home view ────────────────────────────────────────────────────────*/

/* Home view: hide device panel, collapse left bar to icon column only */
.left-ws.home-view { display: none !important; }

/* Collapsed: left-bar shrinks to left-tools width, title hides */
.left-bar.home-view,
.left-bar.panel-collapsed {
    width: 4.5vw;
}

body:has(.left-bar.home-view) .header-content,
body:has(.left-bar.panel-collapsed) .header-content {
    width: 4.5vw;
    padding-left: 0;
    padding-right: 0;
    justify-content: center;
}
body:has(.left-bar.home-view) .title,
body:has(.left-bar.panel-collapsed) .title {
    display: none;
}

.zenith-home-inner {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.zenith-home-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 20px;
    text-align: center;
}

#zenith-home-cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    /* max 4 cards × 260px + 3 gaps × 14px */
    max-width: calc(4 * 260px + 3 * 14px);
    width: 100%;
}

#zenith-home-cards .device-card {
    width: 260px;
    flex-shrink: 0;
    padding: 16px;
    cursor: default;
}

#zenith-home-cards .device-card-btn {
    padding: 9px 10px;
    font-size: 0.78rem;
    min-height: 36px;
}

#zenith-home-cards .device-card-btn svg { width: 13px; height: 13px; }

.zenith-home-add-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 24px;
    padding: 9px 18px;
    background: transparent;
    border: 1px solid #333;
    border-radius: 8px;
    color: #888;
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.zenith-home-add-btn:hover {
    border-color: #555;
    color: #ccc;
}

/* ── Zenith main container ────────────────────────────────────────────────── */

.zenith-container {
    flex: 1;
    display: flex;
    background: #000;
    overflow: hidden;
    position: relative;
}

.zenith-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
}

/* Stream view */

.stream-topbar {
    position: absolute;
    top: 16px;
    left: 5%;
    z-index: 10;
}

.stream-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #333;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    opacity: 0.4;
    transition: opacity 0.3s;
}
.stream-badge.live {
    opacity: 1;
    border-color: rgba(11, 207, 37, 0.4);
}

.badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #444;
    transition: background 0.3s;
}
.stream-badge.live .badge-dot {
    background: #0bcf25;
    box-shadow: 0 0 6px #0bcf25;
    animation: pulse-dot 2s ease infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.badge-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #d9d9d9;
}

#zenith-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.stream-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}
.overlay-msg {
    font-size: 0.88rem;
    color: #555;
    text-align: center;
    white-space: pre-line;
}

.connecting-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(217, 217, 217, 0.1);
    border-top-color: #0088f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Sessions player view */

.player-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: #2a2a2a;
}
.player-empty-state svg { width: 48px; height: 48px; stroke: #2a2a2a; }
.player-empty-state span { font-size: 0.85rem; }

#zenith-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Quality toggle */

.stream-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
}


.stream-share-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #ccc;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 4px 10px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background 0.15s, border-color 0.15s;
}

.stream-share-btn:hover {
    background: rgba(0,0,0,0.7);
    border-color: rgba(255,255,255,0.3);
    color: #fff;
}

.stream-share-btn svg { width: 13px; height: 13px; }

.viewer-download-btn {
    pointer-events: all;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: #ddd;
    font-size: 0.82rem;
    padding: 6px 12px;
    cursor: pointer;
    text-decoration: none;
    backdrop-filter: blur(6px);
    transition: background 0.15s;
    flex-shrink: 0;
}

.viewer-download-btn:hover { background: rgba(0,0,0,0.75); color: #fff; }
.viewer-download-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.player-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    font-size: 0.78rem;
    color: #555;
}
/* ── Device bar ──────────────────────────────────────────────────────────────*/

.sidebar-devices-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 8px;
    flex-shrink: 0;
}

.sidebar-devices-title {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #d9d9d9;
}

.device-add-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,136,241,0.12);
    border: 1px solid rgba(0,136,241,0.25);
    border-radius: 7px;
    cursor: pointer;
    color: #0088f1;
    flex-shrink: 0;
    transition: background 0.15s;
}

.device-add-btn:hover { background: rgba(0,136,241,0.22); }
.device-add-btn svg { width: 12px; height: 12px; }

/* ── Add Device modal ────────────────────────────────────────────────────────*/

.add-device-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-device-card {
    background: #0d1219;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 32px;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.add-device-title {
    font-size: 1rem;
    font-weight: 600;
    color: #d9d9d9;
    margin: 0;
}

.add-device-hint {
    font-size: 0.8rem;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

.add-device-example {
    font-size: 0.78rem;
    color: #444;
    margin: 0;
}

.device-code-input {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 12px;
    color: #d9d9d9;
    font-size: 1.6rem;
    font-family: monospace;
    letter-spacing: 0.2em;
    text-align: center;
    text-transform: uppercase;
    width: 100%;
    margin-top: 8px;
    transition: border-color 0.15s;
}

.device-code-input:focus {
    outline: none;
    border-color: #0088f1;
}

.device-code-input.input-error {
    border-color: #e05555;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    60%       { transform: translateX(6px); }
}

.device-name-input {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 10px 12px;
    color: #d9d9d9;
    font-size: 0.85rem;
    width: 100%;
    transition: border-color 0.15s;
}

.device-name-input:focus {
    outline: none;
    border-color: rgba(255,255,255,0.2);
}

.device-name-input::placeholder,
.device-code-input::placeholder { color: #333; }

.add-device-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.add-device-cancel {
    flex: 1;
    padding: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: #888;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.add-device-cancel:hover { background: rgba(255,255,255,0.09); }

.add-device-save {
    flex: 2;
    padding: 10px;
    background: #0088f1;
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.15s;
}

.add-device-save:hover { background: #0077d6; }

/* ── Settings modal ──────────────────────────────────────────────────────────*/

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

.settings-card {
    background: #0d1219;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 28px;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

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

.settings-title {
    font-size: 1rem;
    font-weight: 600;
    color: #d9d9d9;
    margin: 0;
}

.settings-close {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.settings-close:hover { color: #d9d9d9; }

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-section-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #555;
    margin: 0;
}

.settings-danger-btn {
    background: rgba(224, 85, 85, 0.08);
    border: 1px solid rgba(224, 85, 85, 0.25);
    border-radius: 8px;
    color: #e05555;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 10px 14px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
}

.settings-danger-btn:hover {
    background: rgba(224, 85, 85, 0.15);
    border-color: rgba(224, 85, 85, 0.45);
}

.settings-danger-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.settings-divider {
    height: 1px;
    background: rgba(255,255,255,0.07);
}

.settings-about {
    align-items: center;
    gap: 6px;
    padding: 8px 0 4px;
}

.settings-about-logo {
    width: 40px;
    height: 40px;
    opacity: 0.8;
    margin-bottom: 4px;
}

.settings-about-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #d9d9d9;
    margin: 0;
}

.settings-about-sub {
    font-size: 0.8rem;
    color: #555;
    margin: 0;
}

.settings-about-version {
    font-size: 0.75rem;
    color: #3a3a3a;
    margin: 0;
    margin-top: 4px;
}

/* ── Media Filter Bar ──────────────────────────────────────────────────────── */

.media-filter-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    gap: 6px;
}

.filter-chip {
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    background: transparent;
    color: #777;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.filter-chip:hover:not(:disabled) {
    background: rgba(255,255,255,0.07);
    color: #bbb;
}

.filter-chip.active {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.25);
    color: #eee;
}

.filter-chip--disabled {
    opacity: 0.3;
    cursor: not-allowed;
    font-style: italic;
}

/* ── Month Picker Dropdown ─────────────────────────────────────────────────── */

.month-picker-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 100;
    background: #1c1c1c;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    padding: 12px;
    width: 220px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.month-picker-year-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.month-picker-year {
    font-size: 0.9rem;
    font-weight: 600;
    color: #ddd;
}

.month-picker-arrow {
    background: none;
    border: none;
    color: #888;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.month-picker-arrow:hover { background: rgba(255,255,255,0.08); color: #eee; }

.month-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 10px;
}

.month-cell {
    padding: 7px 4px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: none;
    color: #555;
    font-size: 0.78rem;
    cursor: pointer;
    text-align: center;
    transition: background 0.12s, color 0.12s;
}

.month-cell:hover { background: rgba(255,255,255,0.07); color: #bbb; }

.month-cell--has-media { color: #ccc; }

.month-cell--active {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.25);
    color: #fff;
    font-weight: 600;
}

.month-picker-clear {
    width: 100%;
    padding: 6px;
    background: none;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 7px;
    color: #666;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.month-picker-clear:hover { background: rgba(255,255,255,0.06); color: #aaa; }

/* ── Media Explorer ────────────────────────────────────────────────────────── */

.media-explorer {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: #2a2a2a transparent;
}
.media-explorer::-webkit-scrollbar { width: 4px; }
.media-explorer::-webkit-scrollbar-track { background: transparent; }
.media-explorer::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 4px; }
.media-explorer::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

.media-day-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0 10px;
    color: #555;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.media-day-header:first-child { margin-top: 4px; }

.media-day-header::before,
.media-day-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.07);
}

.media-grid-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, 204px);
    gap: 12px;
    margin-bottom: 8px;
}

.explorer-empty {
    color: #555;
    font-size: 0.9rem;
    text-align: center;
    padding: 48px 0;
    grid-column: 1 / -1;
}

.media-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    display: flex;
    flex-direction: column;
}

.media-card:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
    transform: translateY(-2px);
}

.media-card-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    display: block;
    background: #111;
    overflow: hidden;
    position: relative;
}

.media-card-thumb--video {
    position: relative;
}

.media-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-card-thumb--video {
    background: #0d0d0d;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
    color: rgba(255,255,255,0.25);
}

.media-card-thumb--has-img {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.media-card-thumb--has-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-card-tag {
    position: absolute;
    bottom: 5px;
    right: 6px;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: rgba(0,0,0,0.65);
    color: rgba(255,255,255,0.75);
    padding: 0 6px;
    height: 16px;
    line-height: 16px;
    border-radius: 4px;
    border: 1px solid transparent;
    backdrop-filter: blur(4px);
    pointer-events: none;
    display: inline-flex;
    align-items: center;
}

.media-card-tag--video  { border-color: rgba(0,136,241,0.5); color: rgba(100,180,255,0.9); }
.media-card-tag--image  { border-color: rgba(46,204,113,0.5); color: rgba(100,220,150,0.9); }

.media-card-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.15s;
    color: #fff;
}

.media-card:hover .media-card-play-overlay { opacity: 1; }

.media-card-meta {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.media-card-time {
    font-size: 0.82rem;
    font-weight: 600;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-card-date {
    font-size: 0.72rem;
    color: #555;
}

/* ── Media Viewer ──────────────────────────────────────────────────────────── */

.media-viewer {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #000;
}

.viewer-topbar {
    position: absolute;
    top: 12px;
    left: 5%;
    right: 5%;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.viewer-back-btn {
    pointer-events: all;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: #ddd;
    font-size: 0.82rem;
    padding: 6px 12px;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background 0.15s;
    flex-shrink: 0;
}

.viewer-back-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.viewer-back-btn:hover { background: rgba(0,0,0,0.75); }

.viewer-title {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(6px);
    padding: 6px 10px;
    border-radius: 6px;
    pointer-events: none;
}

#zenith-player,
#zenith-image {
    flex: 1;
    width: 100%;
    min-height: 0;
    object-fit: contain;
    background: #000;
    display: block;
}

/* ── Mobile bottom tab bar ─────────────────────────────────────────────────── */

.mobile-tab-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: #080808;
    border-top: 1px solid rgba(255,255,255,0.08);
    align-items: center;
    justify-content: space-around;
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 20px;
    background: transparent;
    border: none;
    color: #555;
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    min-width: 64px;
    min-height: 44px;
    transition: color 0.15s;
}

.mobile-tab.active { color: #0088f1; }

.mobile-tab-icon {
    width: 22px;
    height: 22px;
    stroke: currentColor;
}

/* ── Mobile devices drawer ─────────────────────────────────────────────────── */

.mobile-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 300;
    backdrop-filter: blur(4px);
}

.mobile-devices-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    background: #0d1219;
    border-top: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px 16px 0 0;
    z-index: 301;
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom, 8px);
    animation: drawer-up 0.22s ease;
}

@keyframes drawer-up {
    from { transform: translateY(30%); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}

.mobile-drawer-handle {
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    margin: 12px auto 4px;
    flex-shrink: 0;
}

.mobile-device-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 12px 12px;
    overflow-y: auto;
}

/* ── Mobile breakpoint (≤ 768px) ───────────────────────────────────────────── */

@media (max-width: 768px) {
    /* Hide desktop left bar */
    .left-bar { display: none !important; }

    /* Zenith container fills full width */
    .zenith-container { width: 100% !important; }

    /* Show mobile tab bar when visible class is set */
    .mobile-tab-bar.visible { display: flex; }

    /* Zenith views: leave room for header (50px) and tab bar (64px) */
    .zenith-view {
        top: 50px;
        bottom: 64px;
        left: 0;
        right: 0;
    }

    /* Stream: bigger touch targets */
    .stream-share-btn {
        padding: 10px 16px;
        font-size: 0.84rem;
    }
    .stream-share-btn svg { width: 16px; height: 16px; }

    /* Viewer: bigger back/download buttons */
    .viewer-back-btn,
    .viewer-download-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    .viewer-back-btn svg,
    .viewer-download-btn svg { width: 16px; height: 16px; }

    /* Filter bar: compact on mobile */
    .media-filter-bar { padding: 5px 10px; gap: 6px; }
    .filter-group { gap: 4px; }
    .filter-chip { padding: 5px 10px; font-size: 0.74rem; }

    /* Home cards: full-width on phone */
    #zenith-home-cards .device-card { width: 100%; }
    .zenith-home-inner { padding: 16px; justify-content: flex-start; }

    /* Device add button: bigger */
    .device-add-btn { width: 36px; height: 36px; }
    .device-add-btn svg { width: 16px; height: 16px; }

    /* Media grid: 2 columns on phone */
    .media-grid-row {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }

    /* Add device modal: safe width */
    .add-device-card { width: min(90vw, 340px); padding: 24px 20px; }

    /* Month picker: don't clip on small screens */
    .month-picker-dropdown { width: min(85vw, 220px); }

    /* Header: slightly tighter */
    .app-header { height: 44px; }
    .logo { width: 32px; height: 32px; }
    .title { font-size: 1.2rem; }

    /* Adjust zenith view top for smaller header */
    .zenith-view { top: 44px; }
}
