:root {
    --font-current: 'Inter', sans-serif;
    --text-light: #2c2c2c;
    --text-dark: #f5f5f7;
    --bg-dark-base: #0a0a0a;
    --bg-light-base: #f7f4f0;
    --transition-speed: 0.35s;
    --accent-glow-dark: rgba(255, 255, 255, 0.15);
    --accent-glow-light: rgba(200, 160, 120, 0.4);
    --modal-bg-light: rgba(255, 255, 255, 0.95);
    --modal-bg-dark: rgba(20, 20, 20, 0.95);
    --modal-text-light: #2c2c2c;
    --modal-text-dark: #f0f0f0;
    --animation-speed: 1.0;
    --scrollbar-color: rgba(128, 128, 128, 0.3);
    --scrollbar-color-light: rgba(0, 0, 0, 0.3);
    --scrollbar-color-dark: rgba(255, 255, 255, 0.3);
}

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

*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
*::-webkit-scrollbar-track {
    background: transparent;
}
*::-webkit-scrollbar-thumb {
    background: var(--scrollbar-color);
    border-radius: 10px;
    transition: background 0.3s;
}
*::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.5);
}
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-color) transparent;
}

body {
    font-family: var(--font-current);
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
    background: var(--bg-light-base);
    color: var(--text-light);
    transition: background 0.3s ease, color 0.3s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body.light-theme {
    --scrollbar-color: var(--scrollbar-color-light);
}

body.dark-theme {
    background: #0a0a0a;
    color: var(--text-dark);
    --scrollbar-color: var(--scrollbar-color-dark);
}

body.light-gradient {
    background: radial-gradient(circle at 10% 30%, #fbeae6, transparent 40%),
                radial-gradient(circle at 90% 70%, #e6f0f5, transparent 50%),
                radial-gradient(circle at 50% 100%, #f0ede8, transparent 70%),
                #faf7f2;
}
body.dark-gradient {
    background: #0a0a0a;
}

.bg-image-layer {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover; background-position: center;
    z-index: -2; transition: opacity 0.3s; opacity: 0;
}
.bg-image-layer.active { opacity: 1; }
.bg-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.25); z-index: -1; display: none;
}
.bg-overlay.active { display: block; }

.widget {
    position: absolute;
    cursor: default;
    transition: left 0.3s ease, top 0.3s ease;
    will-change: transform;
    white-space: nowrap;
    font-weight: 400;
    line-height: 1.3;
    text-shadow: 0 0 8px rgba(255,255,255,0.1);
    pointer-events: none;
    min-width: 20px;
    min-height: 20px;
    z-index: 10;
}
.dark-theme .widget { text-shadow: 0 0 10px rgba(0,0,0,0.5); }
.widget.edit-mode {
    cursor: grab;
    outline: 1px dashed rgba(128,128,128,0.6);
    outline-offset: 4px;
    pointer-events: auto;
}
.widget.edit-mode:active {
    cursor: grabbing;
    outline-color: #e67e22;
}
.widget.dragging { transition: none !important; }

#time-widget { top: 12%; left: 50%; transform: translateX(-50%); font-size: 4.5rem; font-weight: 700; letter-spacing: -1px; }
#date-widget { top: 27%; left: 50%; transform: translateX(-50%); font-size: 1.8rem; font-weight: 400; opacity: 0.9; }
#weather-widget { top: 38%; left: 50%; transform: translateX(-50%); font-size: 1.6rem; font-weight: 400; display: flex; align-items: center; gap: 12px; }
#quote-widget { bottom: 12%; left: 8%; font-size: 1.2rem; max-width: 320px; white-space: normal; font-style: italic; font-weight: 300; opacity: 0.85; }
#crypto-widget { top: 15%; right: 6%; font-size: 1.3rem; font-weight: 500; text-align: right; }

.fab {
    position: fixed;
    width: 50px; height: 50px; border-radius: 50%;
    background: rgba(50, 50, 60, 0.8);
    backdrop-filter: blur(6px);
    color: white; border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 100; transition: 0.3s;
}
.fab:hover { background: rgba(70, 70, 90, 0.9); transform: scale(1.05); }
.fab.hidden { display: none; }
#edit-fab { bottom: 24px; right: 24px; background: rgba(60, 60, 70, 0.8); }
#settings-fab { bottom: 84px; right: 24px; background: rgba(50, 50, 60, 0.8); }
#add-widget-fab { bottom: 144px; right: 24px; background: rgba(50, 50, 60, 0.8); display: none; }

.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    z-index: 200; display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content {
    background: var(--modal-bg-light);
    backdrop-filter: blur(12px);
    border-radius: 32px; padding: 28px;
    width: 90%; max-width: 500px; max-height: 80vh; overflow-y: auto;
    color: var(--modal-text-light);
    transition: background 0.3s, color 0.3s;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-color) transparent;
    padding-right: 35px;
}
.modal-content::-webkit-scrollbar {
    width: 6px;
    margin-right: 10px;
}
.modal-content::-webkit-scrollbar-thumb {
    background: var(--scrollbar-color);
    border-radius: 10px;
}
.dark-theme .modal-content { background: var(--modal-bg-dark); color: var(--modal-text-dark); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 1.8rem; font-weight: 600; }
.close-modal { background: none; border: none; color: #ccc; font-size: 2rem; cursor: pointer; }
.section-title { font-size: 1.2rem; margin: 20px 0 12px; color: inherit; opacity: 0.8; }
.preview-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.bg-thumb { width: 80px; height: 60px; border-radius: 12px; cursor: pointer; background-size: cover; background-position: center; border: 2px solid transparent; transition: 0.2s; }
.bg-thumb:hover { border-color: #e67e22; transform: scale(1.05); }
.btn { background: rgba(0,0,0,0.1); border: none; color: inherit; padding: 12px 20px; border-radius: 40px; cursor: pointer; font-weight: 500; transition: 0.2s; margin: 6px 0; }
.dark-theme .btn { background: rgba(255,255,255,0.15); }
.btn:hover { background: rgba(0,0,0,0.2); }
.dark-theme .btn:hover { background: rgba(255,255,255,0.25); }
.btn-primary { background: #e67e22; color: white; }
.btn-primary:hover { background: #cf711f; }
.btn-danger { background: #e74c3c; color: white; }
.preset-btn { display: inline-block; margin: 4px; padding: 8px 16px; background: rgba(0,0,0,0.1); border-radius: 20px; cursor: pointer; transition: 0.2s; }
.dark-theme .preset-btn { background: rgba(255,255,255,0.1); }
.preset-btn:hover { background: rgba(0,0,0,0.2); }
.dark-theme .preset-btn:hover { background: rgba(255,255,255,0.2); }

.toggle-switch { position: relative; display: inline-block; width: 50px; height: 26px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.3); transition: 0.3s; border-radius: 34px; }
.dark-theme .toggle-slider { background-color: rgba(255,255,255,0.3); }
.toggle-slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: 0.3s; border-radius: 50%; }
.toggle-switch input:checked + .toggle-slider { background-color: #e67e22; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(24px); }

.drop-zone { border: 2px dashed rgba(128,128,128,0.5); border-radius: 16px; padding: 20px; text-align: center; cursor: pointer; transition: 0.3s; margin: 10px 0; }
.drop-zone:hover, .drop-zone.drag-over { border-color: #e67e22; background: rgba(230,126,34,0.1); }
.drop-zone i { font-size: 2rem; margin-bottom: 10px; }

.context-menu {
    position: fixed;
    background: rgba(30, 30, 40, 0.97);
    backdrop-filter: blur(8px);
    border-radius: 16px;
    padding: 8px;
    min-width: 300px;
    max-width: 360px;
    z-index: 300;
    color: #f0f0f0;
    box-shadow: 0 12px 30px rgba(0,0,0,0.6);
    display: none;
    max-height: 80vh;
    overflow-y: auto;
}
.context-menu.active { display: block; }
.context-menu-item { padding: 10px 16px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 10px; font-size: 0.95rem; flex-wrap: wrap; }
.context-menu-item:hover { background: rgba(255,255,255,0.1); }
.context-menu-divider { height: 1px; background: rgba(255,255,255,0.15); margin: 4px 0; }
.color-picker-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.color-picker-row input { width: 30px; height: 30px; border: none; background: none; cursor: pointer; }
.font-navigation { display: flex; align-items: center; gap: 10px; width: 100%; }
.font-nav-btn { background: rgba(255,255,255,0.2); border: none; color: white; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.font-nav-btn:hover { background: rgba(255,255,255,0.3); }
.font-name { flex: 1; text-align: center; font-size: 0.9rem; }
input[type="number"], input[type="text"] { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.3); color: white; padding: 4px 8px; border-radius: 4px; width: 60px; }
input[type="text"] { width: 120px; }
.style-toggle { background: none; border: 1px solid rgba(255,255,255,0.3); color: white; padding: 4px 8px; border-radius: 4px; cursor: pointer; margin: 0 4px; }
.style-toggle.active { background: #e67e22; border-color: #e67e22; }

.guide-line { position: fixed; background: rgba(230, 126, 34, 0.7); pointer-events: none; z-index: 150; display: none; box-shadow: 0 0 4px rgba(230, 126, 34, 0.5); }
.guide-line.vertical { width: 1px; top: 0; bottom: 0; }
.guide-line.horizontal { height: 1px; left: 0; right: 0; }
.guide-line.active { display: block; }

.input-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 400; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.input-modal.active { opacity: 1; pointer-events: auto; }
.input-modal-content { background: var(--modal-bg-light); border-radius: 20px; padding: 24px; width: 90%; max-width: 400px; color: var(--modal-text-light); }
.dark-theme .input-modal-content { background: var(--modal-bg-dark); color: var(--modal-text-dark); }
.input-modal textarea, .input-modal input { width: 100%; padding: 10px; margin: 10px 0; border-radius: 8px; border: 1px solid rgba(128,128,128,0.3); background: rgba(255,255,255,0.1); color: inherit; }
.dark-theme .input-modal textarea { background: rgba(255,255,255,0.05); }

.widget-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.widget-option { padding: 15px; border-radius: 12px; background: rgba(0,0,0,0.05); cursor: pointer; text-align: center; transition: 0.2s; }
.dark-theme .widget-option { background: rgba(255,255,255,0.05); }
.widget-option:hover { background: rgba(230,126,34,0.2); transform: translateY(-2px); }
.widget-option i { font-size: 2rem; margin-bottom: 8px; display: block; }

.custom-widget-iframe { width: 100%; height: 100%; border: none; background: transparent; pointer-events: auto; }
.widget.custom-iframe { pointer-events: auto; }
.disable-context-menu-toggle-row { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; }

.lang-btn { padding: 8px 16px; border-radius: 20px; cursor: pointer; background: rgba(0,0,0,0.1); border: 2px solid transparent; transition: 0.2s; }
.dark-theme .lang-btn { background: rgba(255,255,255,0.1); }
.lang-btn.active { border-color: #e67e22; background: rgba(230,126,34,0.2); }

.weather-settings { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.weather-settings input { width: 100%; padding: 8px; border-radius: 8px; border: 1px solid rgba(128,128,128,0.3); background: rgba(255,255,255,0.1); color: inherit; }
.dark-theme .weather-settings input { background: rgba(255,255,255,0.05); }