:root {
    --tile-opacity: .72;
    --glass: rgba(255,255,255,.72);
    --glass-strong: rgba(255,255,255,.86);
    --border: rgba(255,255,255,.78);
    --text: #1d2633;
    --muted: #687383;
    --shadow: 0 12px 35px rgba(30,45,70,.13);
    --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: "Segoe UI", Inter, system-ui, sans-serif;
    color: var(--text);
}

body {
    background: #eaf0f6;
}

#background {
    --background-opacity: .56;
    position: fixed;
    inset: 0;
    z-index: -2;
    overflow: hidden;
    background: center/cover no-repeat;
    transition: background .4s ease;
}

#backgroundVideo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    pointer-events: none;
}

#backgroundVideo.active { display: block; }

#backgroundOverlay {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 25% 70%, rgba(255,255,255,.30), transparent 28%),
        radial-gradient(circle at 80% 30%, rgba(255,255,255,.20), transparent 25%),
        rgba(241,246,251,var(--background-opacity));
    backdrop-filter: blur(1px);
    pointer-events: none;
}

#desktop {
    width: 100vw;
    height: 100vh;
    position: relative;
}

#topbar {
    height: 72px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px 8px;
    position: relative;
    z-index: 50;
}

#tabs {
    display: flex;
    gap: 7px;
    align-items: center;
    max-width: calc(100vw - 150px);
    overflow-x: auto;
    scrollbar-width: none;
}

#tabs::-webkit-scrollbar { display: none; }

.desktop-tab {
    border: 1px solid rgba(255,255,255,.55);
    background: rgba(255,255,255,.42);
    color: #526070;
    padding: 9px 17px;
    border-radius: 13px;
    cursor: pointer;
    white-space: nowrap;
    backdrop-filter: blur(14px);
    box-shadow: 0 3px 12px rgba(20,35,55,.05);
    transition: .18s ease;
}

.desktop-tab:hover {
    background: rgba(255,255,255,.7);
    transform: translateY(-1px);
}

.desktop-tab.active {
    background: rgba(255,255,255,.86);
    color: #182331;
    box-shadow: 0 7px 22px rgba(30,45,70,.12);
}

.top-spacer { flex: 1; }

.top-button,
.quick-add {
    border: 1px solid rgba(255,255,255,.72);
    background: rgba(255,255,255,.58);
    color: #3f4b5b;
    cursor: pointer;
    backdrop-filter: blur(16px);
    box-shadow: 0 5px 18px rgba(30,45,70,.09);
    transition: .18s ease;
}

.top-button {
    width: 37px;
    height: 37px;
    border-radius: 12px;
    font-size: 18px;
}

.top-button:hover,
.quick-add:hover {
    background: rgba(255,255,255,.88);
    transform: translateY(-1px);
}

#canvas {
    position: absolute;
    inset: 72px 0 0;
    overflow: auto;
    scrollbar-width: thin;
}

#tiles {
    position: relative;
    min-width: 1800px;
    min-height: 1000px;
    width: 100%;
    height: calc(100vh - 72px);
}

.tile {
    position: absolute;
    min-width: 120px;
    min-height: 80px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,var(--tile-opacity));
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px) saturate(120%);
    overflow: hidden;
    user-select: none;
    transition: box-shadow .15s ease, transform .15s ease;
}

.tile:hover {
    box-shadow: 0 17px 40px rgba(30,45,70,.18);
}

.tile.dragging {
    z-index: 1000 !important;
    opacity: .9;
    transform: scale(1.025);
    cursor: grabbing;
}

.tile-header {
    position: absolute;
    right: 8px;
    top: 7px;
    display: flex;
    gap: 3px;
    z-index: 4;
    opacity: 0;
    transition: opacity .15s;
}

.tile:hover .tile-header { opacity: 1; }

.tile-action {
    width: 25px;
    height: 25px;
    border: 0;
    border-radius: 8px;
    background: rgba(255,255,255,.72);
    color: #566274;
    cursor: pointer;
}

.tile-action:hover { background: white; }

.tile-resize {
    position: absolute;
    width: 16px;
    height: 16px;
    right: 2px;
    bottom: 2px;
    cursor: nwse-resize;
    opacity: .35;
}

.tile-resize::after {
    content: "";
    position: absolute;
    right: 3px;
    bottom: 3px;
    width: 8px;
    height: 8px;
    border-right: 2px solid #687383;
    border-bottom: 2px solid #687383;
}


.spectrum-tile {
    padding: 0;
}

.spectrum-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.link-tile {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    cursor: pointer;
}

.link-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    object-fit: contain;
    margin-bottom: 10px;
    background: rgba(255,255,255,.65);
}

.link-title {
    font-weight: 600;
    font-size: 15px;
}

.link-url {
    color: var(--muted);
    font-size: 11px;
    margin-top: 4px;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clock-tile {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 22px;
}

.clock-time {
    font-size: 42px;
    line-height: 1;
    font-weight: 500;
    letter-spacing: -2px;
}

.clock-date {
    margin-top: 10px;
    color: var(--muted);
    font-size: 14px;
}

.weather-tile {
    padding: 20px;
}

.weather-city {
    font-size: 13px;
    color: var(--muted);
}

.weather-main {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.weather-temp {
    font-size: 40px;
    font-weight: 500;
}

.weather-icon { font-size: 36px; }

.weather-info {
    color: var(--muted);
    font-size: 12px;
}

.note-tile {
    padding: 20px;
}

.note-title {
    font-weight: 650;
    margin-bottom: 10px;
}

.note-body {
    width: 100%;
    height: calc(100% - 30px);
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 13px;
}

.calendar-tile {
    padding: 18px;
}

.calendar-title {
    font-weight: 650;
    margin-bottom: 14px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    font-size: 12px;
    text-align: center;
}

.calendar-grid span {
    padding: 5px 0;
}

.calendar-grid .dow {
    color: var(--muted);
    font-weight: 600;
}

.calendar-grid .today {
    background: rgba(80,130,210,.75);
    color: white;
    border-radius: 8px;
}

.empty-hint {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
    text-align: center;
    color: rgba(60,75,95,.45);
    pointer-events: none;
    transition: opacity .2s;
}

.empty-hint.hidden { opacity: 0; }

.empty-icon {
    font-size: 48px;
    font-weight: 200;
}

.empty-hint small {
    display: block;
    margin-top: 7px;
    font-size: 12px;
}

.quick-add {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    font-size: 27px;
    z-index: 60;
}

.floating-menu {
    position: fixed;
    right: 24px;
    bottom: 82px;
    width: 190px;
    padding: 7px;
    background: rgba(255,255,255,.88);
    border: 1px solid rgba(255,255,255,.9);
    border-radius: 15px;
    box-shadow: 0 16px 40px rgba(30,45,70,.18);
    backdrop-filter: blur(20px);
    z-index: 100;
}

.floating-menu.hidden { display: none; }

.floating-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    background: transparent;
    padding: 10px;
    border-radius: 9px;
    text-align: left;
    cursor: pointer;
    color: #354151;
}

.floating-menu button:hover { background: rgba(100,130,170,.1); }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(30,40,55,.25);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden { display: none; }

.modal-card {
    position: relative;
    width: min(440px, calc(100vw - 30px));
    padding: 28px;
    background: rgba(255,255,255,.93);
    border-radius: 20px;
    box-shadow: 0 25px 70px rgba(20,30,50,.25);
}

.modal-card h2 {
    margin: 0 0 20px;
    font-size: 20px;
}

.modal-close {
    position: absolute;
    right: 15px;
    top: 12px;
    border: 0;
    background: transparent;
    font-size: 25px;
    color: #687383;
    cursor: pointer;
}

.form-row {
    margin-bottom: 15px;
}

.form-row label {
    display: block;
    margin-bottom: 6px;
    color: #566274;
    font-size: 13px;
}

.form-row input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d7dee7;
    border-radius: 10px;
    outline: none;
    font: inherit;
}

.form-row input:focus {
    border-color: #91afd2;
}

.modal-submit {
    border: 0;
    border-radius: 10px;
    padding: 11px 18px;
    background: #394d66;
    color: white;
    cursor: pointer;
}

.modal-submit:hover { background: #293b51; }

@media (max-width: 700px) {
    #topbar { padding-left: 10px; padding-right: 10px; }
    .desktop-tab { padding: 8px 12px; }
    .quick-add { right: 15px; bottom: 15px; }
    .floating-menu { right: 15px; bottom: 72px; }
    .media-panel { right: 15px; width: calc(100vw - 30px); }
}


/* Reproductor multimedia global (persiste entre escritorios) */
.media-panel {
    position: fixed;
    top: 62px;
    right: 20px;
    width: 300px;
    padding: 14px;
    background: rgba(255,255,255,.9);
    border: 1px solid rgba(255,255,255,.9);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(30,45,70,.18);
    backdrop-filter: blur(20px);
    z-index: 110;
}

.media-panel.hidden { display: none; }

.media-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.media-panel-title {
    font-weight: 650;
    font-size: 14px;
    color: var(--text);
}

.media-display { width:100%; height:105px; margin-top:4px; border-radius:11px; background:rgba(20,28,38,.82); object-fit:contain; }
.media-display.is-audio { height:52px; }
.media-display.is-video { height:130px; }
.media-controls { display:flex; align-items:center; gap:6px; margin-top:7px; }
.media-control { border:0; background:rgba(255,255,255,.72); color:#435064; border-radius:8px; padding:7px 10px; cursor:pointer; }
.media-control:hover { background:rgba(255,255,255,.95); }
.media-status { color:var(--muted); font-size:11px; margin-top:6px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.media-playlist { max-height:180px; overflow-y:auto; margin-top:8px; padding-right:2px; }
.playlist-item { display:flex; align-items:center; gap:7px; width:100%; border:0; background:transparent; color:#4c5868; padding:6px 7px; border-radius:7px; text-align:left; cursor:pointer; font-size:11px; }
.playlist-item:hover { background:rgba(255,255,255,.62); }
.playlist-item.active { background:rgba(255,255,255,.82); color:#202b3a; font-weight:600; }
.playlist-icon { width:16px; flex:0 0 16px; text-align:center; }
.playlist-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* Radio (Radio Browser) */
.radio-search { display:flex; gap:6px; margin-top:2px; }
.radio-search input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #d7dee7;
    border-radius: 8px;
    outline: none;
    font: inherit;
    font-size: 12px;
}
.radio-search input:focus { border-color: #91afd2; }

.radio-now-playing { display:flex; align-items:center; gap:9px; margin-top:10px; }
.radio-logo { width:38px; height:38px; border-radius:8px; object-fit:contain; background:rgba(20,28,38,.08); flex:0 0 38px; visibility:hidden; }
.radio-now-text { min-width:0; flex:1; }
.radio-name { font-size:12px; font-weight:650; color:var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.radio-info { font-size:11px; color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.radio-playpause { flex:0 0 auto; font-size:14px; padding:7px 11px; }

.radio-stations { margin-top:9px; }
.radio-station { align-items:center; }
.radio-station-logo { width:26px; height:26px; border-radius:6px; object-fit:contain; background:rgba(20,28,38,.08); flex:0 0 26px; }
.radio-station-name { display:flex; flex-direction:column; gap:2px; }
.radio-station-details { color:var(--muted); font-weight:400; font-size:10px; }
.radio-empty { color:var(--muted); font-size:11px; padding:8px 4px; }


/* Configuración */
.settings-section {
    padding: 0 0 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid rgba(100,120,145,.16);
}

.settings-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 14px;
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    cursor: pointer;
}

.settings-toggle-row span {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.settings-toggle-row strong { font-size: 14px; }
.settings-toggle-row small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.settings-toggle-row.compact { margin-top: 10px; font-size: 13px; }

.settings-toggle-row input[type="checkbox"] {
    appearance: none;
    width: 42px;
    height: 24px;
    flex: 0 0 auto;
    border-radius: 20px;
    background: #c7d0da;
    position: relative;
    cursor: pointer;
    transition: .2s ease;
}

.settings-toggle-row input[type="checkbox"]::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    transition: .2s ease;
}

.settings-toggle-row input[type="checkbox"]:checked { background: #4b6f9d; }
.settings-toggle-row input[type="checkbox"]:checked::after { transform: translateX(18px); }

.file-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.file-row input[type="file"] {
    min-width: 0;
    flex: 1;
    padding: 8px;
    font-size: 11px;
    border: 1px solid #d7dee7;
    border-radius: 10px;
    background: rgba(255,255,255,.72);
}

.settings-file-name {
    margin-top: 7px;
    color: var(--muted);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.range-input {
    width: 100%;
    accent-color: #4b6f9d;
    cursor: pointer;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 10px;
    margin-top: 3px;
}

.settings-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.modal-secondary {
    border: 1px solid #d7dee7;
    border-radius: 10px;
    padding: 9px 12px;
    background: rgba(255,255,255,.72);
    color: var(--text);
    cursor: pointer;
}

.modal-secondary:hover { background: rgba(255,255,255,.95); }
.modal-secondary.danger { color: white; background: #9b4d4d; border-color: #9b4d4d; }
.modal-secondary.danger:hover { background: #813f3f; }

/* Modo oscuro */
body.dark-mode {
    --glass: rgba(24,31,42,.72);
    --glass-strong: rgba(25,33,45,.88);
    --border: rgba(255,255,255,.16);
    --text: #edf2f7;
    --muted: #aab5c2;
    --shadow: 0 12px 35px rgba(0,0,0,.30);
    background: #111722;
}


body.dark-mode .tile {
    background: rgba(24,31,42,var(--tile-opacity));
}

body.dark-mode #backgroundOverlay {
    background:
        radial-gradient(circle at 25% 70%, rgba(255,255,255,.08), transparent 28%),
        radial-gradient(circle at 80% 30%, rgba(255,255,255,.06), transparent 25%),
        rgba(10,15,24,var(--background-opacity));
}

body.dark-mode .desktop-tab,
body.dark-mode .top-button,
body.dark-mode .quick-add {
    background: rgba(25,34,47,.62);
    border-color: rgba(255,255,255,.14);
    color: #dbe4ee;
}

body.dark-mode .desktop-tab:hover,
body.dark-mode .top-button:hover,
body.dark-mode .quick-add:hover { background: rgba(45,56,72,.86); }
body.dark-mode .desktop-tab.active { background: rgba(49,62,80,.92); color: #fff; }
body.dark-mode .tile-action { background: rgba(35,45,59,.82); color: #dbe4ee; }
body.dark-mode .tile-action:hover { background: #4a586b; }
body.dark-mode .link-url,
body.dark-mode .weather-city,
body.dark-mode .weather-info,
body.dark-mode .clock-date { color: var(--muted); }
body.dark-mode .link-icon { background: rgba(255,255,255,.12); }
body.dark-mode .floating-menu,
body.dark-mode .modal-card,
body.dark-mode .media-panel {
    background: rgba(24,31,42,.94);
    border-color: rgba(255,255,255,.12);
    color: var(--text);
}
body.dark-mode .floating-menu button { color: #dce5ef; }
body.dark-mode .floating-menu button:hover { background: rgba(255,255,255,.08); }
body.dark-mode .form-row label,
body.dark-mode .settings-section-title { color: var(--muted); }
body.dark-mode .form-row input,
body.dark-mode .file-row input[type="file"] {
    background: rgba(12,18,27,.72);
    border-color: rgba(255,255,255,.14);
    color: var(--text);
}
body.dark-mode .modal-close { color: #aab5c2; }
body.dark-mode .modal-secondary { background: rgba(40,51,66,.82); border-color: rgba(255,255,255,.14); color: #e7edf4; }
body.dark-mode .modal-secondary:hover { background: rgba(55,68,85,.92); }
body.dark-mode .media-control { background: rgba(40,51,66,.82); color: #e7edf4; }
body.dark-mode .media-control:hover { background: rgba(65,78,96,.95); }
body.dark-mode .playlist-item { color: #c5d0dc; }
body.dark-mode .playlist-item:hover { background: rgba(255,255,255,.07); }
body.dark-mode .playlist-item.active { background: rgba(255,255,255,.12); color: #fff; }
body.dark-mode .empty-hint { color: rgba(220,230,240,.45); }
body.dark-mode .radio-search input {
    background: rgba(12,18,27,.72);
    border-color: rgba(255,255,255,.14);
    color: var(--text);
}
body.dark-mode .radio-logo,
body.dark-mode .radio-station-logo { background: rgba(255,255,255,.1); }
