/* Base Styles */
:root {
    --bg-primary: #252525;
    --bg-secondary: #333333;
    --bg-tertiary: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --text-disabled: #999999;
    --border-color: #444444;
    --border-light: #3c3c3c;
    --button-bg: #404040;
    --button-hover: #505050;
    --button-active: #222222;
    --input-bg: #1e1e1e;
    --input-border: #3c3c3c;
    --header-bg-start: #1e1e1e;
    --header-bg-end: #2d2d2d;
    --header-bg: linear-gradient(135deg, var(--header-bg-start), var(--header-bg-end));
    --window-header-active-bg: var(--header-bg);
    --window-header-inactive-bg: var(--border-light);
    --header-text: #0aefff;
    --taskbar-bg: #2a2a2a;
    --accent: #0078d7;
    --accent-light: rgba(0, 120, 215, 0.3);
    --scrollbar-track: #1e1e1e;
    --scrollbar-thumb: #3c3c3c;
    --scrollbar-thumb-hover: #4a4a4a;
    --desktop-bg: #1e1e1e;
    --window-buttons-bg: #333333;
    --window-buttons-border: #3c3c3c;
    --btn-border: #555555;
    --theme-card-bg: #1e1e1e;
    --theme-card-border: #444444;
    --clear-btn-bg: #c00;
    --clear-btn-border: #900;
    --clear-btn-hover: #a00;
    --icon-shadow: rgba(255, 255, 255, 0.1);
    --input-border-focus: #0078d7;
    --icon-hover-bg: rgba(0, 120, 215, 0.2);
    --icon-selected-bg: rgba(0, 120, 215, 0.3);

    /* Additional variables for full theming */
    --white: #ffffff;
    --black: #000000;
    --muted: #666666;
    --mid-gray: #4a4a4a;
    --dark: #222222;
    --overlay-white: rgba(255, 255, 255, 0.1);
    --inset-white-04: rgba(255, 255, 255, 0.04);
    --shadow-50: rgba(0, 0, 0, 0.5);
    --shadow-40: rgba(0, 0, 0, 0.4);
    --shadow-100: rgba(0, 0, 0, 1);
    --shadow-90: rgba(0, 0, 0, 0.9);
    --drop-shadow-color: rgba(0, 0, 0, 0.3);
    --accent-border: rgba(0, 120, 215, 0.8);
    --start-btn-top: #444444;
    --start-btn-bottom: #333333;
    --start-btn-bg: linear-gradient(to bottom, var(--start-btn-top), var(--start-btn-bottom));
    --start-btn-hover-top: #505050;
    /* Button text color should be theme controlled */
    --button-text: var(--white);
    --start-btn-hover-bottom: #3a3a3a;
    /* Taskbar tab theming */
    --taskbar-tab-active-bg: var(--button-active);
    --taskbar-tab-inactive-bg: var(--bg-secondary);
    --taskbar-tab-active-text: var(--white);
    --taskbar-tab-inactive-text: var(--text-primary);
    --taskbar-tab-hover: var(--button-hover);
    /* Start button icon fill */
    --start-icon-fill: var(--white);
    /* Properties / monitor preview */
    /* Central panel background used for Control Panel, tab areas and dialog footers.
         Default to the tertiary background so panels match window content unless
         a theme overrides `--panel-bg` explicitly. */
    --panel-bg: var(--bg-tertiary);
    --properties-preview-bg: var(--panel-bg);
    /* Panel border defaults to the panel background so windows appear unified */
    --panel-border: var(--panel-bg);
    /* Optional: allow themes to adjust window shadow separately */
    --window-shadow: var(--shadow-50);
    --start-btn-hover-bg: linear-gradient(to bottom, var(--start-btn-hover-top), var(--start-btn-hover-bottom));
    --link-color: #4a9eff;
    --border-3a: #3a3a3a;
    --folder-glow-rgb: 0, 180, 255;
    --danger: #ff4444;
    --danger-hover: #ff6666;
    --danger-strong: #cc0000;
    --warning: #ffcc00;
    --success: #00cc00;
    --frameless: #0099ff;
    --appfullscreen: #9966ff;
    --avatar-text: var(--white);
    --avatar-image-filter: none;
    --avatar-bg: transparent;
    /* Desktop icon / folder label color (prefer light text for legibility over varied wallpapers) */
    --icon-label-color: var(--white);
    --accent-60: rgba(0, 120, 215, 0.6);
    --overlay-black-20: rgba(0, 0, 0, 0.2);
    --text-muted: #b3b3b3;
    --overlay-gray-95: rgba(100, 100, 100, 0.95);
    --thin-mode-bg: rgba(74, 74, 74, 0.5);
    --thin-mode-hover: rgba(100, 100, 100, 0.9);
    --tab-hover: #3e3e3e;
    --inset-white-15: rgba(255, 255, 255, 0.15);
    --accent-dark: #0c5ba5;
    --shadow-60: rgba(0, 0, 0, 0.6);
    /* Clock & taskbar time theming */
    --clock-face-bg: #111111;
    --clock-face-stroke: #444444;
    --clock-tick: #666666;
    --clock-hand-hour: #ffffff;
    --clock-hand-minute: #ffffff;
    --clock-hand-second: #ff4d4d;
    --clock-digital: var(--text-primary);
    --clock-date: var(--text-secondary);
    --taskbar-time-color: var(--text-primary);
    --clock-action: #ff6b6b;
    /* primary action color for clock buttons (start/pause) */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Arial, sans-serif;
    scrollbar-width: thick;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

html,
body {
    height: 100%;
    overflow: hidden;
    /* Prevent mobile browsers from scrolling/zooming when windows are dragged off-screen */
    touch-action: none;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    /* Fixed positioning helps prevent iOS Safari from revealing the URL bar on scroll */
    position: fixed;
    width: 100%;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
}

/* Desktop */
.desktop {
    flex: 1;
    position: relative;
    padding: 20px;
    background-image: url('/images/wallpapers/gtwallpaper.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* Prevent text selection during marquee/drag */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Clip windows that are dragged off-screen to prevent mobile scrolling/zooming */
    overflow: hidden;
    /* Prevent touch gestures from triggering page scroll/zoom on mobile */
    touch-action: none;
    overscroll-behavior: contain;
}

.desktop-icon {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Ensure content starts from top so icon never moves */
    justify-content: flex-start;
    text-align: center;
    width: 92px;
    height: 92px;
    margin: 4px;
    padding: 5px;
    cursor: pointer;
    z-index: 1;
    border-radius: 5px;
    outline: none;
    /* Prevent browser focus outline */
    transition: background-color 0.2s;
    /* Prevent text selection on icons */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Prevent touch callout on mobile */
    -webkit-touch-callout: none;
}

/* Icons inside folder windows should flow naturally */
.folder-icons-grid .desktop-icon {
    position: relative;
    margin: 0;
    /* Grid handles gap */
    width: 92px;
    /* Fixed width to match desktop */
    min-width: 92px;
    /* Prevent crushing in flex/grid */
    height: 92px;
}

.desktop-icon:hover {
    background: var(--overlay-white);
}

.desktop-icon.selected {
    background: var(--icon-selected-bg);
    border: 1px solid var(--accent-border);
    z-index: 2;
    /* Ensure selected icon is above unselected (1) but safely below windows (starts at 10) */
}

/* Drop target highlight for folders */
.desktop-icon.drop-target {
    background: var(--icon-selected-bg) !important;
    border: 2px dashed var(--accent);
    transform: scale(1.05);
    z-index: 100 !important;
}

/* Taskbar time styling */
.taskbar-time {
    color: var(--taskbar-time-color);
    text-align: right;
    line-height: 1;
    font-weight: 600;
}

/* Theme-aware styles for built-in Clock app */
.fp-clock-view {
    color: var(--clock-digital);
}

.fp-clock-view #fp-analog circle {
    fill: var(--clock-face-bg);
    stroke: var(--clock-face-stroke);
}

.fp-clock-view #fp-ticks line {
    stroke: var(--clock-tick);
}

.fp-clock-view #fp-hour {
    stroke: var(--clock-hand-hour);
}

.fp-clock-view #fp-minute {
    stroke: var(--clock-hand-minute);
}

.fp-clock-view #fp-second {
    stroke: var(--clock-hand-second);
}

.fp-clock-view #fp-digital {
    color: var(--clock-digital);
}

.fp-clock-view #fp-date {
    color: var(--clock-date);
}

.selection-box {
    position: absolute;
    border: 1px solid var(--accent-border);
    background-color: var(--icon-hover-bg);
    pointer-events: none;
    z-index: 9999;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 5px;
    display: none;
    flex-direction: column;
    padding: 5px 0;
    z-index: 10000;
    min-width: 150px;
    box-shadow: 0 4px 10px var(--shadow-50);
}


.context-menu-item {
    padding: 8px 20px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.2s;
    user-select: none;
}

.context-menu-item:hover:not(.disabled) {
    background: var(--button-hover);
}

.context-menu-item.disabled {
    color: var(--text-disabled);
    cursor: not-allowed;
    opacity: 0.5;
}

.context-menu-separator {
    height: 1px;
    background: var(--border-light);
    margin: 5px 0;
}

.desktop-icon svg,
.desktop-icon img {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    margin-bottom: 4px;
    object-fit: contain;
}

/* Text Label - Always Absolute to prevent jumping */
.desktop-icon span {
    position: absolute;
    /* 5px padding + 60px icon + 4px gap = 69px */
    top: 69px;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;

    font-size: 12px;
    color: var(--icon-label-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.85), 0 0 5px rgba(0, 0, 0, 0.6);
    line-height: 1.35;
    /* Slightly increased for readability */
    text-align: center;

    /* 2 lines limitation logic */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    /* Ensure long words break */

    /* Fixed height for 2 lines: 1.35 * 12px * 2 ~= 32.4px. Using 35px to be safe */
    height: 35px;
    margin: 0;
    pointer-events: none;
    /* Text shouldn't interfere with icon clicks normally */
}

/* When selected: Remove clamps and let it flow downwards */
.desktop-icon.selected span {
    display: block;
    /* Switch to block to remove flex constraints */
    height: auto;
    max-height: none;
    width: 90px;
    /* Match unselected width to prevent text reflow */

    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;

    /* Visuals for readability over other icons */
    background: transparent;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 1), 0 0 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.8);

    padding-bottom: 5px;
    z-index: 999;
}

/* Full text overlay - shown when clicking icon to reveal full name */
.desktop-icon .full-name-overlay {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 68px;
    font-size: 12px;
    color: var(--icon-label-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.85), 0 0 5px rgba(0, 0, 0, 0.6);
    background: rgba(0, 0, 0, 0.8);
    padding: 3px 6px;
    border-radius: 3px;
    white-space: nowrap;
    z-index: 200;
    pointer-events: none;
    /* Clicks pass through */
    display: none;
    max-width: 200px;
    word-break: break-word;
    white-space: normal;
    text-align: center;
}

.desktop-icon.selected .full-name-overlay {
    display: none;
    /* Don't show overlay when selected, the span already shows full name */
}

/* Taskbar */
.taskbar {
    height: 50px;
    background: var(--taskbar-bg);
    border-top: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    padding: 0;
    position: relative;
    box-shadow: 0 -2px 6px var(--shadow-40);
    z-index: 30;
}

.start-btn {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--start-btn-bg);
    position: relative;
    transition: all 0.2s ease;
    border-right: 1px solid var(--dark);
    margin: 0;
    padding: 0;
}

.start-btn svg {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 1px 1px var(--drop-shadow-color));
}

.start-btn svg rect {
    fill: var(--start-icon-fill);
}

.start-btn:hover {
    background: var(--start-btn-hover-bg);
    box-shadow: inset 0 1px 0 var(--overlay-white);
}

.start-btn:active,
.start-btn.active {
    background: var(--button-active);
    box-shadow: inset 0 2px 5px var(--shadow-50);
}

.taskbar-icons {
    flex: 1;
    display: flex;
    gap: 2px;
    margin-left: 10px;
    height: 100%;
    align-items: center;
    overflow: hidden;
}

.taskbar-time {
    font-size: 13px;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    cursor: pointer;
}

/* Start Menu */
.start-menu {
    position: absolute;
    bottom: 50px;
    left: 0;
    width: 380px;
    max-height: calc(100vh - 20px);
    min-height: 200px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 5px;
    display: none;
    flex-direction: column;
    padding: 10px;
    z-index: 1200;
    box-shadow: 2px 2px 10px var(--shadow-50);
    transform-origin: bottom left;
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0;
    box-sizing: border-box;
    transform: scale(0.95);
    overflow: hidden;
}

.start-menu.show {
    display: flex;
    animation: startMenuOpen 0.2s forwards;
}

.start-menu-body {
    position: relative;
    flex: 1;
    min-height: 120px;
    overflow: hidden;
}

.start-menu.search-mode .start-menu-body {
    display: none;
}

.start-view,
.programs-view {
    position: absolute;
    inset: 0;
    padding-right: 4px;
    padding-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.2s ease, opacity 0.2s ease;
    scrollbar-gutter: stable;
}

.programs-view {
    transform: translateX(20px);
    opacity: 0;
    pointer-events: none;
}

.start-menu.programs-mode .start-view {
    transform: translateX(-20px);
    opacity: 0;
    pointer-events: none;
}

.start-menu.programs-mode .programs-view {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.start-menu-spacer {
    flex: 1;
}

/* Ensure button text follows theme (uses --button-text when available) */
button,
.btn {
    color: var(--button-text, var(--text-primary)) !important;
}

/* Make inline SVGs inside buttons inherit color where possible */
button svg,
.btn svg {
    color: inherit;
    fill: currentColor;
}

/* High-contrast forced styles (strictly override appearance) */
[data-theme='high-contrast'] .btn,
[data-theme='high-contrast'] button {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffff00 !important;
    box-shadow: none !important;
}

[data-theme='high-contrast'] .tab,
[data-theme='high-contrast'] .nav-tab {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffff00 !important;
}

[data-theme='high-contrast'] .tab.active,
[data-theme='high-contrast'] .nav-tab.active {
    background: #ffff00 !important;
    color: #000000 !important;
    border-color: #ffff00 !important;
}

.programs-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 2px 2px 2px;
}

.programs-back-btn {
    background: var(--button-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s ease, border 0.15s ease;
}

.programs-back-btn:hover {
    background: var(--button-hover);
    border-color: var(--border-light);
}

.start-menu.search-mode .start-menu-main {
    display: none;
}

.start-menu-search {
    position: relative;
    background: var(--bg-tertiary);
    z-index: 3;
    padding: 8px 0 0 0;
    border-top: 1px solid var(--border-light);
    margin-top: 8px;
}

.start-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    padding: 8px 10px;
    box-shadow: inset 0 1px 0 var(--inset-white-04);
}

.start-search-input-wrap i {
    color: var(--text-secondary);
}

.start-search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    font-size: 14px;
}

.start-search-results-panel {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
    padding-right: 4px;
    min-height: 120px;
}

.start-menu.search-mode .start-search-results-panel {
    display: block;
}

.start-menu.search-mode .start-menu-search {
    border-top: 1px solid var(--border-light);
    padding-top: 8px;
}

.start-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.12s ease;
}

.start-search-item .app-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.start-search-item .app-icon svg,
.start-search-item .app-icon img {
    width: 100%;
    height: 100%;
}

.start-search-item:hover {
    background: var(--button-hover);
}

.start-search-item.active {
    background: var(--accent-light);
    border: 1px solid var(--accent-60);
}

.start-search-item .app-name {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.1;
}

.start-search-item .app-id {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.1;
}

.start-search-empty {
    padding: 8px 10px;
    color: var(--text-disabled);
    font-size: 13px;
}

.search-close-btn {
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-close-btn:hover {
    color: var(--button-text);
}

.start-menu-item#restart {
    margin-top: 0;
    border-top: none;
    padding-top: 10px;
}

.start-menu-item.programs-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.start-programs-drawer {
    position: absolute;
    top: 10px;
    left: calc(100% + 10px);
    width: 300px;
    height: calc(100% - 20px);
    background: var(--taskbar-bg);
    border: 1px solid var(--border-light);
    border-radius: 5px;
    box-shadow: 10px 8px 20px var(--shadow-50);
    padding: 10px;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    z-index: 2000;
}

.start-programs-drawer.show {
    display: flex;
}

.start-menu-programs-wrapper {
    position: static;
    overflow: visible;
}

.start-menu-item {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    font-size: 14px;
}

/* User Profile Section */
.user-profile-section {
    display: flex;
    align-items: center;
    padding: 12px 10px;
    background: var(--overlay-black-20);
    border-radius: 5px;
    margin-bottom: 6px;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 12px;
    flex-shrink: 0;
    background: var(--avatar-bg, linear-gradient(135deg, var(--button-bg), var(--button-hover)));
    border: 2px solid var(--border-color);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Allow theme-controlled image filter to adjust avatar contrast for readability */
    filter: var(--avatar-image-filter, none);
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--avatar-text);
    font-size: 20px;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.user-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.start-menu-separator {
    height: 1px;
    background: var(--border-color);
    margin: 6px 0;
}

@keyframes startMenuOpen {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.start-menu-item:hover {
    background: var(--border-light);
}

.start-menu-item:active {
    background: var(--border-color);
}

.start-menu::-webkit-scrollbar {
    width: 8px;
}

.start-menu::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 5px;
}

.start-menu::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 5px;
}

.start-menu::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Context Menu */
.context-menu {
    position: absolute;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 5px;
    display: none;
    flex-direction: column;
    padding: 5px 0;
    z-index: 1000;
}

.context-menu.show {
    display: flex;
}

.context-menu-item {
    padding: 5px 20px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.context-menu-item:hover:not(.disabled) {
    background: var(--border-light);
}

.context-menu-item.disabled {
    color: var(--muted);
    cursor: default;
}

.context-menu-separator {
    height: 1px;
    background: var(--border-light);
    margin: 5px 0;
}

/* Properties Window Specific Styles */
.properties-content {
    padding: 20px;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.6;
}

/* My Computer app styles */
.mycomputer-content {
    padding: 20px;
    color: var(--text-primary);
    font-size: 14px;
    overflow: auto;
    background: var(--bg-secondary);
    border-radius: 5px;
    height: 100%;
    -webkit-overflow-scrolling: touch;
}

.mycomputer-content .mc-title {
    margin-bottom: 15px;
    color: var(--success);
}

.mycomputer-content .mc-section {
    color: var(--warning);
    margin-bottom: 10px;
}

.mycomputer-content hr {
    border-top: 1px solid var(--border-light);
}

.properties-content h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
}

/* Properties preview (monitor / SVG preview) */
.properties-preview {
    background: var(--properties-preview-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    padding: 12px;
    border-radius: 4px;
    display: inline-block;
}

/* Enforce unified panel background so Control Panel, Display/Properties previews,
   tabs, and the footer/button area always match `--panel-bg` (overrides inline styles). */
.properties-window,
.properties-window .tabs,
.properties-window .tab,
.properties-window .tab.active,
.properties-window .tab-content,
.properties-window .window-buttons,
.properties-preview {
    background: var(--panel-bg) !important;
}

.properties-preview svg {
    display: block;
    /* Give SVG area the same backdrop color */
    background-color: var(--properties-preview-bg);
}

/* Ensure text and strokes inside preview SVG follow theme text color */
.properties-preview svg * {
    fill: var(--text-primary) !important;
    stroke: var(--text-primary) !important;
}

/* Target common background rects inside SVG previews and force them to use the preview bg color */
.properties-preview svg>rect:first-child,
.properties-preview svg rect.bg,
.properties-preview svg g.bg rect {
    fill: var(--properties-preview-bg) !important;
}

/* Ensure text inside the preview stays readable and uses text color */
.properties-preview svg text,
.properties-preview svg tspan {
    fill: var(--text-primary) !important;
}

/* Ensure code/text areas in any properties preview are always white (SVG source viewers) */
.properties-preview pre,
.properties-preview code,
.properties-preview textarea {
    color: var(--properties-preview-text) !important;
    background: transparent !important;
    caret-color: #ffffff !important;
}

/* Screensaver animation text uses --ss-anim-color (falls back to --text-primary) */
.ss-anim {
    color: var(--ss-anim-color, var(--text-primary)) !important;
}

.property-row {
    display: flex;
    margin-bottom: 12px;
}

.property-label {
    font-weight: bold;
    min-width: 100px;
    color: var(--text-secondary);
}

.property-value {
    color: var(--text-primary);
    word-break: break-all;
}

.property-value a {
    color: var(--link-color);
    text-decoration: none;
}

.property-value a:hover {
    text-decoration: underline;
}

/* Window System */
.window {
    position: absolute;
    background: var(--bg-tertiary);
    border: 1px solid var(--panel-border, var(--border-light));
    border-radius: 5px;
    /* allow per-theme control of shadow intensity via --window-shadow */
    box-shadow: 0 0 10px var(--window-shadow);
    display: none;
    flex-direction: column;
    min-width: 200px;
    min-height: 150px;
    z-index: 20;
}

.window.show {
    display: flex;
}

.window-header {
    height: 30px;
    background: var(--window-header-inactive-bg);
    color: var(--header-text);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    user-select: none;
}

.drag-handle {
    flex: 1;
    display: flex;
    align-items: center;
    cursor: default;
    touch-action: none;
    min-height: 60px;
}

.window-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 8px;
}

.window-icon-btn {
    width: 22px;
    height: 22px;
    background: var(--button-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.window-icon-btn:hover {
    background: var(--button-hover);
}

.window-icon-btn.active {
    background: var(--accent);
    border-color: var(--accent-dark);
}

.window-title {
    font-size: 14px;
}

.window-controls {
    display: flex;
    gap: 5px;
}

.window-btn {
    width: 20px;
    height: 20px;
    background: var(--mid-gray);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.window-btn.close {
    background: var(--danger);
}

.window-btn.minimize {
    background: var(--warning);
}

.window-btn.maximize {
    background: var(--success);
}

.window-btn.fullscreen {
    background: var(--muted);
}

.window-btn.frameless {
    background: var(--frameless);
}

.window-btn.appfullscreen {
    background: var(--appfullscreen);
}

.window-fullscreen-btn {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 20px;
    background: rgba(var(--bg-primary), 0.9);
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: all 0.2s;
}

.window-fullscreen-btn:hover {
    background: var(--overlay-gray-95);
    height: 25px;
}

/* Thin mode when in app fullscreen or browser fullscreen */
.window-fullscreen-btn.thin-mode {
    height: 5px;
    width: 40px;
    background: var(--thin-mode-bg);
}

.window-fullscreen-btn.thin-mode:hover {
    height: 20px;
    width: 35px;
    background: var(--thin-mode-hover);
}

.window-fullscreen-btn.thin-mode svg {
    opacity: 0;
    transition: opacity 0.2s;
}

.window-fullscreen-btn.thin-mode:hover svg {
    opacity: 1;
}

.window-content {
    flex: 1;
    padding: 10px;
    display: flex;
    flex-direction: column;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) var(--bg-primary);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--button-hover);
}

::-webkit-scrollbar-corner {
    background: var(--bg-primary);
}

.window-content::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

/* Make specific apps run maximized on mobile (applied via JS by adding .mobile-maximized) */
@media (max-width: 520px) {
    .window.mobile-maximized {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 50px !important;
        /* leave room for taskbar */
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        z-index: 9999 !important;
    }

    .window.mobile-maximized .window-header {
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
}

.window-content::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 5px;
}

.window-content::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 5px;
}

.window-content::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: var(--border-light);
    cursor: nwse-resize;
}

.taskbar-tab {
    height: 88%;
    background: var(--taskbar-tab-inactive-bg);
    color: var(--taskbar-tab-inactive-text);
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 60px;
    max-width: 160px;
    box-shadow: inset 0 1px 0 var(--overlay-white),
        0 2px 3px var(--shadow-40);
    margin: 0 3px;
    border-radius: 4px;
    border: 1px solid var(--border-3a);
    transition: all 0.15s ease;
    position: relative;
    top: -1px;
}

.taskbar-tab:hover {
    background: var(--taskbar-tab-hover);
    box-shadow: inset 0 1px 0 var(--inset-white-15),
        0 2px 4px var(--shadow-50);
    border-top: 1px solid var(--btn-border);
}

.taskbar-tab.active {
    background: var(--taskbar-tab-active-bg);
    box-shadow: inset 0 2px 4px var(--shadow-60);
    transform: translateY(1px);
    border: 1px solid var(--taskbar-tab-active-bg);
    color: var(--taskbar-tab-active-text);
}

.taskbar-tab:active {
    background: var(--mid-gray);
    box-shadow: inset 0 2px 4px var(--shadow-40);
    transform: translateY(1px);
}

.taskbar-context-menu {
    position: absolute;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 5px;
    display: none;
    flex-direction: column;
    padding: 5px 0;
    z-index: 32;
}

.taskbar-context-menu.show {
    display: flex;
}

.taskbar-context-menu .context-menu-item {
    padding: 5px 20px;
    cursor: pointer;
    font-size: 14px;
}

.taskbar-context-menu .context-menu-item:hover {
    background: var(--border-light);
}

.window-btn:hover {
    filter: brightness(1.2);
}

.window-btn.minimize:hover svg rect {
    fill: var(--white);
}

.window-btn.maximize:hover svg rect {
    stroke: var(--white);
}

.window-btn.fullscreen:hover svg path {
    stroke: var(--white);
}

.window-btn.close:hover svg path {
    stroke: var(--white);
}

/* Folder Styles */
#folder-container {
    position: relative;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Folder styles (extends desktop-icon) */
.folder:hover {
    background: var(--overlay-white);
}

.folder.folder-glow {
    background: rgba(var(--folder-glow-rgb), 0.3);
    box-shadow: 0 0 15px rgba(var(--folder-glow-rgb), 0.8), inset 0 0 15px rgba(var(--folder-glow-rgb), 0.4);
    transform: scale(1.05);
    transition: all 0.2s ease;
}

/* Folder Context Menu */
#folderContextMenu {
    position: fixed;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 5px;
    display: none;
    flex-direction: column;
    padding: 5px 0;
    z-index: 10001;
    min-width: 150px;
    box-shadow: 0 4px 10px var(--shadow-50);
}

#folderContextMenu.show {
    display: flex;
}

#folderContextMenu .context-item {
    padding: 8px 20px;
    cursor: pointer;
    font-size: 14px;
    color: var(--white);
    transition: background 0.2s;
}

#folderContextMenu .context-item:hover {
    background: var(--border-light);
}

#folderContextMenu .context-item.danger:hover {
    background: var(--danger-strong);
}

/* Folder Window Styles */
.folder-window-content {
    padding: 10px;
    height: 100%;
    overflow-y: auto;
}

.folder-icons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    padding: 10px;
}

.folder-contained-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 5px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    color: var(--icon-label-color);
}

.folder-contained-icon:hover {
    background: var(--overlay-white);
}

.folder-contained-icon svg {
    width: 40px;
    height: 40px;
}

.remove-icon-btn {
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.remove-icon-btn:hover {
    background: var(--danger-hover);
}

/* Icon in folder state */
.desktop-icon.in-folder {
    opacity: 0.5;
    pointer-events: none;
}

/* ========================================
   Cloud Storage / Desktop Files
   ======================================== */

/* Drag and drop highlight */
.desktop.drag-over {
    background-color: rgba(0, 120, 215, 0.1);
    box-shadow: inset 0 0 0 4px var(--accent);
    transition: all 0.2s ease;
}

.desktop.drag-over::after {
    content: 'Drop files to upload';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 600;
    color: var(--accent);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 100;
}

/* Desktop file icon styles */
.desktop-file .icon-image {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.desktop-file .icon-image svg {
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.desktop-file .icon-label {
    font-size: 11px;
    color: var(--icon-label-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.85), 0 0 5px rgba(0, 0, 0, 0.6);
    line-height: 1.2;
    max-width: 80px;
    word-wrap: break-word;
    text-align: center;
}

.desktop-file.dragging {
    opacity: 0.7;
    z-index: 1000;
}

/* File context menu */
.file-context-menu.visible {
    display: flex;
}

/* Upload Progress Popup (bottom-right, above taskbar) */
.upload-progress-overlay {
    position: fixed;
    bottom: 60px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
}

.upload-progress-box {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 16px 20px;
    text-align: left;
    min-width: 280px;
    max-width: 320px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

.upload-progress-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.upload-progress-filename {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-progress-bar {
    height: 8px;
    background: var(--input-bg);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #00b4ff);
    border-radius: 4px;
    transition: width 0.2s ease;
}

.upload-progress-percent {
    font-size: 14px;
    color: var(--accent);
    font-weight: 600;
}

/* Notification Toasts */
.notification-toast {
    position: fixed;
    bottom: 70px;
    right: 20px;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    /* Use dark background with white text for consistent readability */
    color: #fff;
    background: #333;
    border: 1px solid #444;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 11000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.notification-toast.visible {
    transform: translateY(0);
    opacity: 1;
}

.notification-toast.notification-success {
    border-left: 4px solid var(--success, #28a745);
    background: #2d3d2d;
}

.notification-toast.notification-error {
    border-left: 4px solid var(--danger, #dc3545);
    background: #3d2d2d;
}

.notification-toast.notification-info {
    border-left: 4px solid var(--accent, #0078d4);
    background: #2d3d4d;
}

/* ========== My Computer App Styles ========== */
.mycomputer-container {
    padding: 20px;
    color: var(--text-primary);
    font-size: 14px;
    overflow: auto;
    background: var(--bg-primary);
    height: 100%;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.mc-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Drives Grid */
.mc-drives-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.mc-drive-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.mc-drive-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.mc-drive-item.selected {
    background: var(--accent-light);
    border-color: var(--accent);
}

.mc-drive-icon svg {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.mc-drive-info {
    flex: 1;
    min-width: 0;
}

.mc-drive-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.mc-drive-space {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.mc-drive-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.mc-drive-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Quick Access Folders */
.mc-folders-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mc-folder-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    min-width: 100px;
}

.mc-folder-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

.mc-folder-item.selected {
    background: var(--accent-light);
    border-color: var(--accent);
}

.mc-folder-item svg {
    width: 48px;
    height: 48px;
}

.mc-folder-item span {
    font-size: 13px;
    color: var(--text-primary);
}

/* System Info Section */
.mc-system-info {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

.mc-info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.mc-info-row:last-child {
    border-bottom: none;
}

.mc-info-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.mc-info-value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Clipboard cut visual state - items pending move */
.clipboard-cut {
    opacity: 0.5;
    filter: grayscale(30%);
}

.clipboard-cut::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(45deg,
            transparent,
            transparent 4px,
            rgba(0, 0, 0, 0.1) 4px,
            rgba(0, 0, 0, 0.1) 8px);
    pointer-events: none;
    border-radius: 5px;
}