* {
    min-width: 0px;
    min-height: 0px;
    box-sizing: border-box;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.darkmuted {
    --b0: hsl(220, 20%, 10%);
    --b1: hsl(220, 18%, 14%);
    --b2: hsl(220, 16%, 18%);
    --b3: hsl(220, 14%, 22%);
    --b4: hsl(220, 12%, 28%);
    --b5: hsl(220, 10%, 34%);
    --f4: hsl(220, 10%, 60%);
    --f3: hsl(220, 12%, 75%);
    --f2: hsl(220, 14%, 85%);
    --f1: hsl(0, 0%, 98%);
    --accent1: hsl(200, 60%, 50%);
    --accent2: hsl(200, 50%, 60%);
    --error: hsl(0, 60%, 50%);
}

body {
    --fontDefault: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-family: var(--fontDefault);
    background-color: var(--b0);
    color: var(--f2);
    line-height: 1.5;
    font-size: 16px;
}

.btn, .textbox {
    border-radius: 10px;
    border: 1px solid var(--b3);
    background-color: var(--b1);
    color: var(--f2);
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
}

.btn:hover {
    background-color: var(--b4);
    transform: translateY(-1px);
}

.btn:focus-visible {
    outline: 2px solid var(--accent2);
    outline-offset: 2px;
}

.btn.iconOnly .icon {
    margin: 0;
    font-size: 20px;
}

.textbox,
.textbox.textarea > textarea {
    padding: 10px 16px;
    background-color: var(--b1);
    border: 1px solid var(--b3);
    color: var(--f1);
    font-size: 14px;
}

.textbox.textarea {
    padding: 12px 0;
}

.popup {
    border-radius: 12px;
    background-color: var(--b1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--b3);
}

.context {
    border-radius: 10px;
    padding: 6px;
    gap: 6px;
    background-color: var(--b2);
}

.context > .item {
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--f2);
}

.context > .item:hover {
    background-color: var(--b4);
}

label.selectOption input[type="radio"],
label.selectOption input[type="checkbox"] {
    margin-top: 0;
    accent-color: var(--accent1);
}

.tooltip {
    padding: 8px 14px;
    border-radius: 8px;
    background-color: var(--b2);
    color: var(--f3);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.toastOverlay > .toast > .body {
    padding: 16px 10px;
    background-color: var(--b1);
    border-radius: 8px;
}

.popup > .body {
    padding: 10px;
}

.page-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#main {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    background-color: var(--b0);
}

#navbar {
    padding: 12px 20px;
    border-bottom: 1px solid var(--b3);
    background-color: var(--b1);
}

#fileHeader .icon {
    font-family: 'Material Symbols Filled Rounded';
    font-size: 24px;
    color: var(--f3);
    user-select: none;
}

#fileHeader .path {
    font-size: 13px;
    color: var(--f4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#fileHeader .name {
    font-size: 16px;
    color: var(--f1);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#controls {
    padding: 10px 20px;
    border-bottom: 1px solid var(--b3);
    background-color: var(--b1);
    overflow-x: auto;
    overflow-y: hidden;
}

#controls::-webkit-scrollbar {
    height: 4px;
    background: transparent;
}

#controls::-webkit-scrollbar-thumb {
    background: var(--b4);
    border-radius: 4px;
}

#controls::-webkit-scrollbar-thumb:hover {
    background: var(--b5);
}

#controls .sep {
    width: 1px;
    height: 24px;
    margin: 0 8px;
    background-color: var(--b3);
}

#controls .selectOption {
    font-size: 14px;
    color: var(--f2);
    margin-top: 6px;
}

#controls .selectOption input {
    font-size: 24px;
}

#fileColHeadings {
    padding: 12px 24px 8px 24px;
    font-weight: 600;
    color: var(--f4);
    font-size: 13px;
    user-select: none;
    overflow-y: scroll;
    scrollbar-gutter: stable;
    background-color: var(--b1);
}

#fileColHeadings.tiles {
    display: none;
}

#files {
    overflow-x: hidden;
    overflow-y: auto;
    height: 0;
    padding: 6px;
    scrollbar-gutter: stable;
}

#files:not(.tiles) > .heading {
    display: none;
}

#files.tiles > .heading {
    display: block;
    padding: 14px 24px 6px 24px;
    font-weight: 600;
    color: var(--f4);
    font-size: 13px;
    user-select: none;
    flex-shrink: 0;
}

#files > .section {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: 4px;
}

#files.tiles > .section {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.fileEntry {
    height: auto;
    padding: 8px 24px;
    justify-content: flex-start;
    --bg: transparent;
    --fg: var(--f2);
    --bgHover: var(--b4);
    --bgActive: var(--b5);
    font-weight: 400;
    text-align: left;
    gap: 12px;
    border-radius: 8px;
}

.fileEntry:hover {
    background-color: var(--bgHover);
}

.fileEntry:active {
    background-color: var(--bgActive);
}

.fileEntry.selected {
    --bg: var(--accent1);
    --fg: var(--f1);
    --bgHover: var(--accent2);
    --bgActive: var(--accent2);
    background-color: var(--bg);
    color: var(--fg);
    opacity: 1 !important;
    border: 1px solid var(--accent2);
    box-shadow: 0 0 8px rgba(200, 50%, 60%, 0.3);
}

.fileEntry.selected:hover {
    background-color: var(--bgHover);
}

.fileEntry.selected:active {
    background-color: var(--bgActive);
}

.fileEntry.selected > .icon,
.fileEntry.selected > .nameCont .name,
.fileEntry.selected > .nameCont .lower {
    color: var(--f1);
}

.fileEntry.hidden:not(.selected) > * {
    opacity: 0.6;
}

.fileEntry.cut:not(.selected) {
    opacity: 0.6;
}

.permsMatrix .header,
.permsMatrix .cell {
    width: 80px;
    height: 44px;
}

.permsMatrix .cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.permsMatrix .header {
    font-size: 13px;
    color: var(--f3);
    display: flex;
}

.permsMatrix .header.top {
    height: 24px;
    text-align: center;
    justify-content: center;
    padding-bottom: 4px;
}

.permsMatrix .header.left {
    width: 60px;
    text-align: right;
    justify-content: flex-end;
    align-items: center;
}

#preview {
    flex-grow: 1;
    overflow: auto;
    background-color: var(--b1);
    display: block; 
}

#preview.image,
#preview.video {
    background: var(--b0);
    display: flex; 
    align-items: center;
    justify-content: center;
}

#preview.audio {
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#preview.image {
    cursor: grab;
}

#preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Ensure images scale properly */
    margin: auto;
}

#preview video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#preview audio {
    width: 540px;
}

#preview .CodeMirror {
    width: 100%; /* Use full width instead of fixed 1280px */
    height: 100%;
    border: none;
    border-left: 1px solid var(--b3);
    border-right: 1px solid var(--b3);
}

#preview.markdown .rendered {
    width: 100%;
    max-width: 1280px; 
    padding: 24px;
    margin: auto;
}

#progressBar {
    border-radius: 0;
    margin: 0;
    height: 4px;
    background-color: var(--accent1);
    display: none;
}

#progressBar.visible {
    display: block;
}

#statusBar {
    padding: 10px 12px;
    font-size: 14px;
    color: var(--f4);
    border-top: 1px solid var(--b3);
    line-height: 1.4;
}

#statusBar.error {
    color: var(--error);
}

#connectionManager .entry > .icon {
    font-family: 'Material Symbols Outlined Rounded';
    font-size: 28px;
    color: var(--f3);
    user-select: none;
}

#connectionManager .entry > .row {
    gap: 10px 24px;
}

.moveFilesPicker .folders {
    border-radius: 10px;
    padding: 6px;
    gap: 4px;
    border: 1px solid var(--b3);
    height: 320px;
    overflow-y: auto;
    background-color: var(--b1);
}

.file-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.file-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--b3);
}

.file-list a {
    color: var(--accent1);
    text-decoration: none;
    display: flex;
    align-items: center;
}

.file-list a:hover {
    color: var(--accent2);
    text-decoration: underline;
}

.file-icon {
    margin-right: 10px;
}

.file-size {
    color: var(--f4);
    margin-left: 6px;
    font-size: 0.85em;
}

footer {
    background-color: var(--b1);
    color: var(--f4);
    text-align: center;
    padding: 16px;
    font-size: 14px;
    border-top: 1px solid var(--b3);
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .atLeast640px {
        display: none;
    }
}

@media (min-width: 641px) {
    .atMost640px {
        display: none;
    }
}

@media (max-width: 800px) {
    .atLeast800px {
        display: none;
    }
}

@media (min-width: 801px) {
    .atMost800px {
        display: none;
    }
}

@media (max-width: 1000px) {
    .atLeast1000px {
        display: none;
    }
}

@media (min-width: 1001px) {
    .atMost1000px {
        display: none;
    }
}
