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

:root {
    --background-color: #000;
    --secondary-background-color: #222;
    --variable-border-color: #363839;
    --text-color: #fff;
    --bright-text-color: #fff;
    --subdued-text-color: #81878A;
    --disabled-text-color: #888;
    --link-color: #389DCE;
    --link-color-hover: #1a8cc4;
    --secondary-color: #6c757d;
    --success-color: #9AD27D;
    --info-color: #389DCE;
    --warn-color: #FFC956;
    --danger-color: #E1523F;
    --accent-color: #9F7BEA;
    --accent-hover-color: #8a6fd6;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow: hidden;
    background-color: var(--background-color);
    font-family: 'Inter', sans-serif;
    font-size: medium;
    color: var(--subdued-text-color);
    user-select: none; /* Make non-selectable by default */
}

canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--background-color);
    touch-action: none;
    cursor: none; /* Hide system cursor for custom tool cursors */
    /* Prevent context menus and selection on all platforms */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-color);
    line-height: normal;
}

div, p {
    color: var(--subdued-text-color);
    font-size:medium;
    line-height: 1.5em;
}

a {
    color: var(--link-color);
    text-decoration: none;
    cursor: pointer;
}

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

.bold {
    font-weight: bold;
}

.normal {
    font-weight: normal;
}

.bright {
    color: var(--bright-text-color);
}

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

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

.info {
    color: var(--link-color);
}

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

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

.subdued {
    color: var(--subdued-text-color);
}

.large {
    font-size: x-large;
}

.small {
    font-size: small;
}

.hidden {
    display: none !important;
}

.tile {
    border: 1px solid var(--background-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

label {
    color: var(--subdued-text-color);
    display: flex;
    gap: 8px;
    align-items: center;
}

.statusbar {
    position: fixed;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    z-index: 98;
}

.selection-menu {
    position: absolute;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    z-index: 101;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s ease-out, visibility 0.1s ease-out;
    border-radius: 4px;
    background-color: var(--background-color);
}

.selection-menu.show {
    opacity: 1;
    visibility: visible;
}

.statusbar .section, .selection-menu .section {
    display: flex;
    gap: 10px;
    align-items: center;
}

.statusbar .group, .selection-menu .group {
    border-radius: 4px;
    background-color: var(--background-color);
    display: flex;
    gap: 0;
    align-items: center;
}

.statusbar button, .selection-menu button {
    background-color: transparent;
    color: var(--text-color);
    border: none;
    padding: 0 10px;
    cursor: pointer;
    border-radius: 4px;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    font-weight: bold;
    font-size: medium;
    gap: 10px;
}

.statusbar button:hover, .statusbar button.active, .selection-menu button:hover, .selection-menu button.active {
    background-color: var(--secondary-background-color);
}

.statusbar button.disabled, .selection-menu button.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.statusbar button.separator, .selection-menu button.separator {
    color: var(--variable-border-color);
    font-weight: normal;
    font-size:large;
    padding: 0;
    cursor: default;
    min-width: 0;
}

.statusbar button.separator:hover, .selection-menu button.separator:hover {
    background-color: transparent;
}

.tools-container {
    display: flex;
    gap: 5px;
}

.toolbar {
    position: fixed;
    top: 64px;
    bottom: 64px;
    left: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 10px;
    z-index: 98;
    /* Prevent text selection and touch callouts on all platforms */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none;
}

.toolbar .group {
    border-radius: 22px;
    background-color: var(--background-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.toolbar button {
    background-color: var(--background-color);
    color: var(--text-color);
    border: none;
    padding: 0 10px;
    cursor: pointer;
    border-radius: 22px;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    font-weight: bold;
}

.toolbar button:hover, .toolbar button.active {
    background-color: var(--secondary-background-color);
}

.bottombar {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    z-index: 98;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-out, visibility 0.2s ease-out;
}

.bottombar.show {
    opacity: 1;
    visibility: visible;
}

.bottombar .group {
    border-radius: 4px;
    background-color: var(--background-color);
    display: flex;
    gap: 0;
    align-items: center;
}

.bottombar button {
    background-color: transparent;
    color: var(--text-color);
    border: none;
    padding: 0 10px;
    cursor: pointer;
    border-radius: 4px;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    font-weight: bold;
    font-size: medium;
    gap: 10px;
}

.bottombar button:hover, .bottombar button.active {
    background-color: var(--secondary-background-color);
}

.notification {
    position: fixed;
    left: 50%;
    top:0;
    transform: translate(-50%, -100%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    z-index: 100;
    transition: transform 0.5s;
    background-color: var(--secondary-background-color);
    color: var(--text-color);
    border-radius: 4px;
    padding: 10px;
}

.notification.show {
    transform: translate(-50%, 10px);
}

.notification.hide {
    transform: translate(-50%, -100%);
}

.notification.version-mismatch {
    position: fixed;
    top: 20px;
    right: 20px;
    left: auto;
    transform: none;
    background: #ff6b6b;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
    max-width: 400px;
    font-weight: 500;
}

.notification.version-mismatch button {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
    margin-left: 12px;
    font-weight: 500;
    transition: background 0.2s;
}

.notification.version-mismatch button:hover {
    background: rgba(255,255,255,0.3);
}

div.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: flex;
    justify-content: center;
    align-items: center;
}

div.popup {
    position: fixed;
    display: flex;
    flex-direction: column;
    /* gap: 10px; */
    z-index: 100;
    background-color: var(--background-color);
    border: 1px solid var(--secondary-background-color);
    color: var(--text-color);
    border-radius: 14px;
    min-width: 375px;
    max-width: 375px;
    max-height: 92vh;
    max-height: 92dvh; /* Dynamic viewport height - adapts to visible area */
    overflow: visible;
    opacity: 0;
    transition: opacity 0.2s, height 0.2s;
}

.popup.show {
    opacity: 1;
}

.popup .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-direction: row;
    /* margin-bottom: 10px; */
    padding: 0;
}

.popup .header h2 {
    margin: 0;
}

.popup .header.no-tabs {
    margin:10px 10px 0 0;
}

.popup .header.no-tabs h2 {
    margin: 0;
    display: inline-block;
    padding: 0 20px;
}

.popup .header a.info-button {
    color: var(--subdued-text-color);
    text-decoration: none;
    cursor: pointer;
    font-weight:bold;
    font-size:small;
    border: 2px solid var(--subdued-text-color);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup .header .info-button-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    width: 44px;
    border-radius: 4px;
}

.popup .header .info-button-container:hover {
    background-color: var(--secondary-background-color);
}

.popup .content {
    margin:10px 0;
    display: flex;
    flex-direction: column;
    gap: 10px; /* override in children */
}

input[type="text"], input[type="number"], input[type="password"], input[type="email"], textarea {
    background-color: var(--secondary-background-color);
    color: var(--text-color);
    border: 1px solid var(--background-color);
    border-radius: 4px;
    padding: 10px;
    font-size: medium;
    min-width: 80px;
    user-select: auto; /* Allow selection for inputs */
}

input[type="text"]:focus, input[type="number"]:focus, input[type="password"]:focus, input[type="email"]:focus, textarea:focus {
    outline: none;
    border: 1px solid var(--link-color);
}
input[type="text"].error, input[type="number"].error, input[type="password"].error, input[type="email"].error, textarea.error {
    border: 1px solid var(--danger-color);
}



.wide {
    min-width: 80% !important;
}

.popup h1 {
    margin: 10px 0 8px;
}

.popup h4 {
    margin: 5px 0 10px;
}

.popup button, #gallery button {
    color: var(--text-color);
    background-color: var(--secondary-background-color);
    border: none;
    min-height: 44px;
    border-radius: 4px;
    font-size: medium;
    display:inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 12px 20px;
    width: fit-content;
    /* user-select: none; */ /* Removed, inherited from body */
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px;
}

.popup button:hover, #gallery button:hover {
    background-color: var(--background-color);
}

.popup button.disabled, #gallery button.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.popup button.blue, #gallery button.blue {
    background-color: var(--link-color);
}

.popup button.blue:hover, #gallery button.blue:hover {
    background-color: var(--link-color-hover);
}

.popup button.accent {
    background-color: var(--accent-color);
}

.popup button.accent:hover {
    background-color: var(--accent-hover-color);
}

.popup button.two-line {
    flex-direction: column;
    gap: 5px;
    align-items: flex-start;
}

.popup button.border {
    border: 1px solid var(--secondary-background-color);
    background-color: var(--background-color);
}

.popup button.border:hover {
    background-color: var(--secondary-background-color);
}

.popup button.secondary {
    background-color: var(--secondary-background-color);
    border: 1px solid var(--secondary-background-color);
}

.popup button.secondary:hover {
    background-color: var(--background-color);
}

.popup button.small {
    font-size: medium;
    padding: 10px;
    min-height: 34px;
}

.popup button.small.icon {
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 10px;
    padding-left: 30px;
}

.popup button.full {
    width: 100%;
    justify-content: flex-start;
}

.popup .tabs {
    display: flex;
    overflow-y: auto;
}

.popup .tab {
    color: var(--subdued-text-color);
    border: none;
    min-height: 44px;
    min-width: 44px;
    cursor: pointer;
    display:flex;
    align-items: center;
    justify-content: center;
    padding: 0 15px;
    background-repeat: no-repeat;
    background-position: center;
}

.popup .tab:hover {
    background-color: var(--secondary-background-color);
}

.popup .tab.active {
    color: var(--text-color);
    font-weight: bold;
    border-bottom:2px solid var(--text-color);
}

.popup .tab.disabled {
    color: var(--disabled-text-color);
    opacity: 0.3;
    cursor: not-allowed;
}

.popup .tab:first-child {
    border-top-left-radius: 10px;
}

.popup-paged {
    display: flex;
    flex-direction: column; /* Ensure header stays at the top */
    height: 100%; /* Make sure the popup takes up the full height */
    overflow: hidden; /* Prevent overflow */
}

.scroll-container {
    overflow-x: auto; /* Enable horizontal scrolling */
    flex: 1; /* Allow the scroll container to take up remaining space */
}

.popup .page-grid {
    display: flex; /* Use flexbox for horizontal layout */
    flex-wrap: nowrap; /* Prevent wrapping to a new line */
    overflow: auto; /* Enable scrolling */
    align-items: flex-start; /* Align items to the top */
}

.popup .grid-page {
    width: 100%; /* Make each child take up the full width */
    flex-shrink: 0; /* Prevent shrinking */
    flex-grow: 1;
}

.popup .filters {
    display: flex;
    flex-direction: row;
    gap: 4px;
    background-image: url('/img/filters-filter.svg');
    background-position: 20px center; /* moved from left center */
    background-size: 16px;
    background-repeat: no-repeat;
    padding: 0 20px 0 44px; /* adjusted padding to accommodate icon and match margin */
    overflow-y: hidden;
    overflow-x: auto;
}

.popup .filters .filter {
    white-space: nowrap;
    display: inline-block;
    padding: 5px 10px;
    border-radius: 4px;
    color: var(--subdued-text-color);
    font-size: small;
    cursor: pointer;
}

.popup .filters .filter:hover {
    background-color: var(--secondary-background-color);
}

.popup .filters .filter.active {
    background-color: var(--secondary-background-color);
    color: var(--text-color);
    font-weight: bold;
}

.popup .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.section-header h2 {
    margin: 16px 0 0;
}

.popup .input-group {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    width: 100%;
    align-self: stretch;
}

.popup .input-group-no-gap {
    display: flex;
    flex-direction: row;
    gap: 0;
    width: 100%;
    align-self: start;
}

.popup .input-group input, .popup .input-group-no-gap input {
    flex-grow: 1;
}

.popup .move-handle {
    cursor: move;
    background-image: url('/img/overlay-move-handle.svg');
    background-repeat: no-repeat;
    background-position: center 6px;
    opacity: 0.3;
    height: 10px;
    display: block;
    flex-shrink: 0;
}

.popup .resize-handle {
    cursor: ew-resize;
    background-repeat: no-repeat;
    background-size: 14px;
    opacity: 0.3;
    display: block;
    position:absolute;
    z-index: 100;
    width: 18px;
    height: 18px;
    bottom:0;
}

.popup .resize-handle.bottom-left {
    background-image: url('/img/overlay-resize-handle-bl.svg');
    background-position: 4px 0px;
    left: 0;
}

.popup .resize-handle.bottom-right {
    background-image: url('/img/overlay-resize-handle-br.svg');
    background-position: 0px 0px;
    right: 0;
}

.popup .arrow {
    position: absolute;
    top: -11px; /* Shift upwards by arrow height */ /* Adjusted based on previous change */
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    /* Border */
    border-left: 11px solid transparent; /* Adjusted based on previous change */
    border-right: 11px solid transparent; /* Adjusted based on previous change */
    border-bottom: 11px solid var(--secondary-background-color); /* Border color, adjusted size */
}

/* Add back the default ::after rule */
.popup .arrow::after { /* Fill */
    content: "";
    position: absolute;
    top: 1px; /* Position inside border */
    left: -10px; /* Center horizontally, adjusted for size */
    width: 0;
    height: 0;
    border-left: 10px solid transparent; /* Adjusted size */
    border-right: 10px solid transparent; /* Adjusted size */
    border-bottom: 10px solid var(--background-color); /* Fill color, adjusted size */
}

.popup .arrow.flipped {
    transform: translateX(-50%) rotate(180deg);
    top: auto; /* Reset top */
    bottom: -11px; /* Position at the bottom border, adjusted size */
}

.popup .arrow.flipped::after {
    top: 1px; /* Adjust fill position for flipped arrow */
    /* Restore fill properties */
    content: "";
    position: absolute;
    left: -10px; /* Center horizontally, adjusted for size */
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid var(--background-color); /* Fill color */
}

.import-btn {
    color: var(--text-color);
    border: none;
    height: 44px;
    cursor: pointer;
    border-radius: 4px;
    font-size: medium;
    display:flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.import-btn:hover {
    background-color: var(--secondary-background-color);
}

.import-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.import-btn.disabled:hover {
    background-color: transparent;
}

.import-btn img {
    width: 18px;
    height: 18px;
}

.separator {
    border-top: 4px solid var(--secondary-background-color);
    margin: 0;
}

.long-btn {
    color: var(--text-color);
    border: none;
    height: 44px;
    cursor: pointer;
    border-radius: 4px;
    font-size: medium;
    display:flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 0 44px;
    background-position: 12px center;
    background-size: 16px;
    background-repeat: no-repeat;
}

.long-btn:hover {
    background-color: var(--secondary-background-color);
}

.long-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.long-btn.disabled:hover {
    background-color: transparent;
}

.long-btn.blue {
    background-color: var(--link-color);
}

.long-btn.blue:hover {
    background-color: var(--link-color-hover);
}

.long-btn.external {
    color: var(--link-color);
}

.long-btn.danger {
    color: var(--danger-color);
    font-weight: bold;
}

button.icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background-color: transparent;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 4px;
    min-height: 44px;
    min-width: 44px;
    transition: background-color 0.2s;
    background-position: center;
    background-size: 18px;
    background-repeat: no-repeat;
}

button.icon:hover {
    background-color: var(--secondary-background-color);
}

.label-icon {
    min-width: 22px;
    min-height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-position: center;
    background-size: 16px;
    background-repeat: no-repeat;
}

.label-text {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    min-height: 22px;
}

/* Switch */

.switch {
    position: relative;
    display: inline-block;
    min-width: 60px;
    max-width: fit-content;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider { /* Rounded corners */
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #78788055;
    -webkit-transition: .2s;
    transition: .2s;
    border-radius: 34px;
}

.slider:before { /* Circular handle */
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    -webkit-transition: .2s;
    transition: .2s;
    border-radius: 50%;
}

input:checked+.slider { /* Color when checked */
    background-color: #496D6F;
}

input:focus+.slider { /* Optional focus highlight */
    box-shadow: 0 0 1px #78A19C;
}

input:checked+.slider:before { /* Move handle to the right */
    -webkit-transform: translateX(26px);
    -ms-transform: translateX(26px);
    transform: translateX(26px);
}

input[type="checkbox"] {
    width: 12px;
    height: 12px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 2px solid var(--bright-text-color);
    border-radius: 2px;
    cursor: pointer;
}

input[type="checkbox"]:checked {
    background-color: var(--bright-text-color);
}

/* --- Radio Button Styles --- */
input[type="radio"] {
    appearance: none; /* Hide default appearance */
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 16px; /* Size of the outer circle */
    height: 16px;
    border: 2px solid var(--subdued-text-color); /* Default border color */
    border-radius: 50%; /* Make it a circle */
    cursor: pointer;
    position: relative; /* Needed for pseudo-element positioning */
    display: inline-block; /* Ensure proper layout */
    vertical-align: middle; /* Align with label text */
    margin-right: 8px; /* Space between button and text */
    flex-shrink: 0; /* Prevent shrinking in flex layouts */
}

input[type="radio"]:checked {
    border-color: var(--bright-text-color); /* Border color when checked */
}

/* Inner circle for checked state */
input[type="radio"]::after {
    content: '';
    display: block;
    width: 8px; /* Size of the inner circle */
    height: 8px;
    border-radius: 50%;
    background-color: var(--bright-text-color); /* Fill color when checked */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0); /* Center and hide by default */
    transition: transform 0.1s ease-in-out;
}

input[type="radio"]:checked::after {
    transform: translate(-50%, -50%) scale(1); /* Show inner circle when checked */
}

/* Adjust label styles for radio buttons */
label:has(> input[type="radio"]) {
    color: var(--subdued-text-color);
    cursor: pointer; /* Make the whole label clickable */
    display: flex; /* Ensure alignment */
    align-items: center;
}

label:has(> input[type="radio"]:checked) {
    color: var(--bright-text-color); /* Text color when checked */
}
/* --- End Radio Button Styles --- */


label:has(> input[type="checkbox"]) {
    color: var(--subdued-text-color);
}

label:has(> input[type="checkbox"]:checked) {
    color: var(--bright-text-color);
}



.flex {
    display: flex;
    align-items: center;
    gap: 20px;
}

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

.flex-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.flex-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    justify-content: start;
    align-items: start;
}

.flex-column h3 {
    margin-bottom:8px;
}

.debug {
    position: fixed;
    bottom: 10px;
    left: 10px;
    /* background-color: var(--secondary-background-color); */
    color: var(--subdued-text-color);
    padding: 10px;
    border-radius: 4px;
    z-index: 101;
    display: flex;
    gap: 10px;
}

.icon {
    width: 24px;
    height: 24px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 16px;
}

/* Tags */

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

.tag {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 4px;
    background-color: var(--secondary-background-color);
    color: var(--subdued-text-color);
    font-size: small;
    cursor: pointer;
}

video {
    object-fit: cover;
    width: 100%;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

.sidebar {
    position: absolute;
    top: 0px;
    left: 0px;
    bottom: 0px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 90;
    padding: 64px 15px 0 15px;
    width: 240px;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.2s;
}

.sidebar.show {
    transform: translateX(0);
}

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

button.sidebar-item {
    color: var(--text-color);
    background-color: var(--background-color);
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 4px;
    min-height: 44px;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: start;
    gap: 10px;
    font-size: medium;
}

button.sidebar-item:hover {
    background-color: var(--secondary-background-color);
}

button.sidebar-item .thumb {
    width: 44px;
    height: 44px;
    border-radius: 4px;
    border:0;
    background-color: var(--secondary-background-color);
    background-position: center;
    background-repeat: no-repeat;
}

div.bottom-button-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--secondary-background-color);
    border-radius: 30px;
    height: 60px;
    gap: 12px;
    padding: 0 20px;
    z-index: 98;
    cursor: pointer;
}

div.bottom-button {
    color: var(--text-color);
    background-color: var(--secondary-background-color);
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 30px;
    height: 100%;
    width: 100%;
    display: inline-flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    font-size: medium;
}

div.setting {
    display: flex;
    flex-direction: column;
    justify-content: start;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    text-align: center;
    width: min-content;
    background: transparent;
    background-image: none !important;
}

div.setting .round-button {
    background-color: var(--secondary-background-color);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 22px;
    border: 1px solid var(--variable-border-color);
    border-radius: 50%;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: small;
}

div.setting.selected .round-button {
    border: 2px solid var(--bright-text-color);
}

div.setting.selected div {
    color: var(--bright-text-color)
}

div.setting.disabled, div.setting.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

div.setting.locked .round-button {
    background-image: url('/img/filters-locked-dark.svg');
    background-repeat: no-repeat;
    background-position: center bottom 6px;
    background-size: 10px;
}

div.setting .round-button#plain-white {
    background-color: #ffffff;
}

div.setting .round-button#transparent {
    background-image: url('/img/background_transparent_tile.webp');
    background-repeat: repeat;
}

div.setting .round-button#crumpled {
    background-image: url('/img/background_crumpled_tile.webp');
    background-size: cover;
}

div.setting .round-button#lightweight {
    background-image: url('/img/background_lightweight_tile.webp');
    background-size: cover;
}

div.setting .round-button#heavyweight {
    background-image: url('/img/background_heavyweight_tile.webp');
    background-size: cover;
}

div.setting .round-button#rippled {
    background-image: url('/img/background_rippled_tile.webp');
    background-size: cover;
}

div.setting .round-button#blueprint {
    background-image: url('/img/background_blueprint_tile.webp');
    background-size: cover;
}

div.setting .round-button#brown {
    background-image: url('/img/background_brownpaper_tile.webp');
    background-size: cover;
}

div.setting .round-button#darkprint {
    background-image: url('/img/background_darkprint_tile.webp');
    background-size: cover;
}

div.setting .round-button#dot {
    background-image: url('/img/grid-icon-dot.svg');
    background-size: cover;
}

div.setting .round-button#graph {
    background-image: url('/img/grid-icon-graph-paper-1-4.svg');
    background-size: cover;
}

div.setting .round-button#lined {
    background-image: url('/img/grid-icon-lined-paper-medium-ruled.svg');
    background-size: cover;
}

div.setting .round-button#hex {
    background-image: url('/img/grid-icon-hex.svg');
    background-size: cover;
}

div.icon-button-list-group .description {
    margin-bottom: 12px;
}

div.icon-button-list-group h3, 
div.icon-button-list-group .description {
    padding-left: 20px;
    padding-right: 20px;
}

div.icon-button-list-group .flex-scroll {
    padding-left: 20px; 
    padding-right: 20px;
}

.title-set-container.edge-to-edge {
    padding: 0 20px;
}

div.pinned-bottom {
    position: absolute;
    bottom: 0px;
    /* background: linear-gradient(to bottom, transparent, var(--background-color)); */
    padding: 20px 0;
    width: 100%;
}

div.timeline-grid {
    display:flex;
    flex-direction: column;
    gap: 10px;
}

div.timeline-row {
    display:grid;
    grid-template-columns: 24px 1fr;
    gap: 10px;
    align-items: center;
}

div.timeline-icon {
    width: 24px;
    height: 24px;
    border-radius: 11px;
    background-color: var(--secondary-background-color);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 12px;
}

div.timeline-icon#lock {
    background-color: var(--accent-color);
}

div.timeline-text {
    padding: 3px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

div.timeline-line {
    width: 4px;
    height: 100%;
    display: inline-block;
    border-radius: 2px;
    background-color: var(--secondary-background-color);
    margin-left: 10px;
}

div.timeline-line#gradient {
    background: linear-gradient(180deg, var(--accent-color) 0%, var(--secondary-background-color) 100%);
}

div.timeline-grid h4 {
    margin: 0;
}

div.web-location {
    background-repeat: no-repeat;
    background-position: center left;
    background-size: 10px;
    padding-left: 20px;
    font-size: small;
    margin: 0 10px;
}

.banner {
    background-color: var(--secondary-background-color);
}

.banner.success {
    border-left:2px solid var(--success-color);
    background-image: url('/img/special-check.svg');
    background-repeat: no-repeat;
    background-position: 16px center;
    background-size: 16px;
    padding:16px 20px 16px 40px;
}

.banner.rounded {
    border-radius: 4px;
}

.progress-title {
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%);
}

.animation-open, .animation-closed {
    width: 196px;
    height: 196px;
}

.animation-open {
    animation: rotate 3s linear infinite;
    animation-play-state: running;
}

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

/* Icons */

#close, .close {
    background-image: url('/img/menu-close-small.svg');
}

button#info, div#info {
    background-image: url('/img/help-manual.svg');    
}

.tab#info {
    opacity: 0.5;
}

#copy {
    background-image: url('/img/selection-duplicate.svg');
}

#delete {
    background-image: url('/img/selection-delete.svg');
}

#location {
    background-image: url('/img/input-location.svg');
}

#lock {
    background-image: url('/img/filters-locked-dark.svg');
}

#unlock {
    background-image: url('/img/filters-unlocked-dark.svg');
}

#zoom, #search {
    background-image: url('/img/form-search.svg');
}

#rotate {
    background-image: url('/img/filters-rotate-selected.svg');
}

#bell {
    background-image: url('/img/special-bell.svg');
}

#check {
    background-image: url('/img/special-check.svg');
}

#chat {
    background-image: url('/img/help-askusanything.svg');
}

#ios {
    background-image: url('/img/platform-ios.svg');
}

#android {
    background-image: url('/img/platform-android.svg');
}

#windows {
    background-image: url('/img/platform-windows.svg');
}

#back {
    background-image: url('/img/browser-back.svg');
}

#forward {
    background-image: url('/img/browser-forward.svg');
}

#reload {
    background-image: url('/img/browser-reload.svg');
}

#web {
    background-image: url('/img/browser-open-browser.svg');
}

#share {
    background-image: url('/img/menu-export.svg');
}

#work {
    background-image: url('/img/accounts-forwork.svg');
}

#personal {
    background-image: url('/img/accounts-forplay.svg');
}

#school {
    background-image: url('/img/accounts-foreducation.svg');
}

a#settings, button#settings {
    background-image: url('/img/menu-settings.svg');
}

#art-illustration {
    background-image: url('/img/interest-art-illustration.svg');
}

#document-markup {
    background-image: url('/img/interest-document-markup.svg');
}

#note-taking {
    background-image: url('/img/interest-note-taking.svg');
}

#other {
    background-image: url('/img/interest-other.svg');
}

#presenting {
    background-image: url('/img/interest-presenting.svg');
}

#sketching-ideas {
    background-image: url('/img/interest-sketching-ideas.svg');
}

#technical-drawing {
    background-image: url('/img/interest-technical-drawing.svg');
}

#google-signin {
    background-image: url('/img/login-google.svg');
    border: 1px solid var(--variable-border-color);
}

#apple-signin {
    background-image: url('/img/platform-ios.svg');
    border: 1px solid var(--variable-border-color);
}

#microsoft-signin {
    background-image: url('/img/platform-windows.svg');
    border: 1px solid var(--variable-border-color);
}

#account img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
}

/*
#debugLog {
    position: fixed;
    bottom: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: lime;
    padding: 8px;
    font-family: monospace;
    font-size: 11px;
    max-height: 150px;
    width: calc(100% - 10px);
    overflow-y: scroll;
    pointer-events: none;
    z-index: 10000;
    white-space: pre-wrap;
}
*/

/* Rule to enable text selection for content elements */
p, h1, h2, h3, h4, h5, h6, a, label, span {
    user-select: text;
}

/* Grouped scrollbar hiding styles */
.popup,
.popup .header,
.scroll-container,
.popup .page-grid,
.popup .filters,
.sidebar,
.sidebar .header,
.flex-scroll {
    scrollbar-width: none;
}

.popup::-webkit-scrollbar,
.popup .header::-webkit-scrollbar,
.scroll-container::-webkit-scrollbar,
.popup .page-grid::-webkit-scrollbar,
.popup .filters::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.sidebar .header::-webkit-scrollbar,
.flex-scroll::-webkit-scrollbar {
    display: none;
}

/* Color Palette Styles */
.color-palette {
    position: fixed;
    top: 64px; /* Under status bar */
    right: 10px;
    display: flex;
    align-items: stretch;
    background: var(--secondary-background-color);
    /* border: 1px solid var(--variable-border-color); */
    border-radius: 6px;
    overflow: hidden;
    z-index: 90;
    /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); */
    user-select: none;
}

.color-palette .color-cell {
    width: 40px;
    height: 24px;
    cursor: pointer;
    border: none;
    /* border-right: 2px solid var(--variable-border-color); WILL UPDATE IN JS */
    transition: transform 0.1s ease;
    position: relative;
}

.color-palette .color-cell.selected::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.color-palette .drag-handle {
    width: 40px;
    height: 24px;
    cursor: grab;
    background: var(--secondary-background-color);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.color-palette .drag-handle:active {
    cursor: grabbing;
}

.color-palette .drag-handle::before {
    content: '';
    width: 3px;
    height: 3px;
    background: var(--subdued-text-color);
    border-radius: 50%;
    box-shadow: 
        -4px 0 0 var(--subdued-text-color),
        4px 0 0 var(--subdued-text-color);
}

.color-palette.dragging {
    pointer-events: none;
}

.color-palette.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(100%);
}

/* User Icons Styles */
.user-icons-container {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 4px;
    min-width: fit-content;
}

.user-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #666;
    background: var(--background-color);
    /* box-shadow: 0 1px 3px rgba(0,0,0,0.2); */
    filter: invert(1) !important;
}

.user-icon:last-of-type {
    margin-left: 0;
}

.user-icon img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.user-count-remaining {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: 4px;
    color: var(--bright-text-color);
}

.user-icon,
.user-count-remaining {
    transition: all 0.2s ease;
    cursor: pointer;
    flex-shrink: 0;
}

.user-icon:hover,
.user-count-remaining:hover {
    transform: translateY(-1px) scale(1.1);
    /* box-shadow: 0 3px 8px rgba(0,0,0,0.4); */
    z-index: 200 !important;
}

.user-icon img {
    transition: transform 0.2s ease;
}

.user-icon:hover img {
    transform: scale(1.05);
}

/* Ensure the userCount button accommodates variable width */
#userCount {
    width: fit-content !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
}

/* Render Stats Display */
div.render-stats-display {
    position: fixed;
    bottom: 8px;
    left: 8px;
    font-family: 'Inter', monospace;
    color: rgba(129, 135, 138, 0.6);
    z-index: 1000;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.render-stats-display:hover {
    color: rgba(129, 135, 138, 0.9);
}

.render-stats-content {
    display: flex;
    align-items: center;
    white-space: nowrap;
    gap: 0;
    font-size: small;
}

.render-stats-display span {
    font-weight: 400;
}

/* PDF Import Popup */
.popup .content.pdf-content {
    padding: 0 20px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.pdf-footer {
    padding: 10px 20px 20px;
    flex-shrink: 0;
    background-color: var(--background-color);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pdf-footer>div {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
}

.pdf-layout-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: small;
    user-select: none;
}

.pdf-layout-tags {
    display: flex;
    gap: 8px;
}

.pdf-layout-tag {
    padding: 2px 8px;
    border-radius: 4px;
    background-color: var(--background-color);
    cursor: pointer;
    font-size: small;
    transition: all 0.2s ease;
    user-select: none;
}

.pdf-layout-tag:hover {
    background-color: var(--secondary-background-color);
}

.pdf-layout-tag.selected {
    background-color: var(--secondary-background-color);
    color: var(--bright-text-color);
}

#pdf-filter-input {
    width: 100%;
    padding-right: 40px;
}

#pdf-loading {
    text-align: center;
    padding: 20px;
}

#pdf-grid {
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); 
    gap: 15px; 
    overflow-y: auto; 
    flex: 1; 
    min-height: 0;
    align-items: end;
    justify-items: center;
}

.pdf-thumbnail-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: grab;
    width: 100%;
}

.pdf-thumbnail {
    border: 1px solid var(--variable-border-color);
    border-radius: 4px;
    position: relative;
    width: 100%;
    height: auto;
    cursor: pointer;
}

.pdf-thumbnail-wrapper.selected .pdf-thumbnail {
    border: 3px solid var(--info-color);
}

.pdf-page-label {
    font-size: small;
    margin-top: 4px;
    color: var(--subdued-text-color);
}

/* Gallery Styles */
.gallery {
    padding: 84px 20px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    overflow-y: auto;
    height: 100vh;
    align-items: start;
    align-content: start;
    transition: padding-left 0.2s;
}

.gallery.sidebar-open {
    padding-left: 260px;
}

.gallery-item {
    position: relative; /* For absolute delete button */
    /* background-color: var(--secondary-background-color); */
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.gallery-item:hover {
    transform: scale(1.02);
    background-color: var(--secondary-background-color);
    /* box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); */
}

.gallery-item .thumbnail {
    width: 100%;
    aspect-ratio: 4 / 3;
    background-color: #1a1a1a;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* border-bottom: 1px solid var(--variable-border-color); */
    border-radius: 8px;
}

.gallery-item .thumbnail.no-thumbnail {
    /* background-image: url('/img/gallery-newdrawing.svg'); */
    background-size: 48px;
    background-color: var(--variable-border-color);
}

.gallery-item .info {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gallery-item .title {
    color: var(--bright-text-color);
    font-weight: 600;
    font-size: medium;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-item .metadata {
    color: var(--subdued-text-color);
    font-size: small;
}

.gallery-item .delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
    font-size: 18px;
    line-height: 1;
    z-index: 2;
}

.gallery-item:hover .delete-btn {
    opacity: 1;
}

.gallery-item .delete-btn:hover {
    background-color: var(--danger-color);
}

.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100dvh - 104px); /* Account for gallery padding: 84px top + 20px bottom */
    text-align: center;
    gap: 12px;
    padding: 20px;
}

.empty-state h2 {
    color: var(--bright-text-color);
    margin: 0;
}

.empty-state p {
    color: var(--subdued-text-color);
    margin: 0;
}
