:root {
  --accent: #3b82f6;
  --accent-soft: #3b82f633;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #eef1f7;
  --text: #1c2333;
  --muted: #6b7489;
  --border: #d5dae5;
  --taskbar: rgba(20, 26, 40, 0.82);
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.28);
  --wallpaper: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 45%, #93c5fd 100%);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
}
:root[data-theme="dark"] {
  --bg: #11151f;
  --panel: #1a2030;
  --panel-2: #232a3d;
  --text: #e6e9f2;
  --muted: #9aa3b8;
  --border: #323a50;
  --accent-soft: #3b82f655;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; }
button, input, select, textarea { font: inherit; color: inherit; }

#desktop {
  position: fixed; inset: 0 0 48px 0;
  background: var(--wallpaper);
  background-size: cover;
}

/* Iconos del escritorio */
#desktop-icons {
  position: absolute; top: 12px; left: 12px;
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(auto-fill, 92px);
  gap: 6px; height: calc(100% - 24px);
}
.desk-icon {
  width: 84px; height: 88px; border: 0; background: none; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); cursor: default; font-size: 12px;
}
.desk-icon .ico { font-size: 34px; line-height: 1; }
.desk-icon:hover, .desk-icon:focus { background: rgba(255,255,255,.18); outline: none; }

/* Ventanas: la capa ocupa el escritorio pero deja pasar los clics a los iconos */
#windows { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.window {
  position: absolute; display: flex; flex-direction: column;
  min-width: 320px; min-height: 200px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); overflow: hidden; pointer-events: auto;
  animation: pop .12s ease-out;
}
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.window.maximized { inset: 0 !important; width: auto !important; height: auto !important; border-radius: 0; }
.window.minimized { display: none; }
.window:not(.focused) .titlebar { opacity: .75; }
.titlebar {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 12px;
  background: var(--panel-2); border-bottom: 1px solid var(--border); user-select: none; flex: none;
}
.titlebar .title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.titlebar button {
  width: 30px; height: 26px; border: 0; border-radius: 6px; background: none; cursor: pointer;
}
.titlebar button:hover { background: var(--border); }
.titlebar button.close:hover { background: #ef4444; color: #fff; }
.window-body { flex: 1; overflow: auto; position: relative; display: flex; flex-direction: column; }
.resize-handle { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; }

/* Barra de tareas */
#taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: 48px;
  display: flex; align-items: center; gap: 6px; padding: 0 8px;
  background: var(--taskbar); backdrop-filter: blur(14px); color: #fff; z-index: 10000;
}
#taskbar button {
  height: 36px; border: 0; border-radius: 8px; background: rgba(255,255,255,.08); color: #fff; padding: 0 12px; cursor: pointer;
}
#taskbar button:hover { background: rgba(255,255,255,.18); }
#task-buttons { flex: 1; display: flex; gap: 4px; overflow: hidden; }
#task-buttons button { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#task-buttons button.active { background: rgba(255,255,255,.25); box-shadow: inset 0 -2px 0 var(--accent); }
#tray { display: flex; gap: 14px; padding: 0 6px; font-size: 13px; }
#tray-net { color: #86efac; }
.logo { font-size: 18px; }

/* Menú de inicio */
#start-menu {
  position: fixed; left: 8px; bottom: 56px; width: 300px; max-height: 70vh;
  display: flex; flex-direction: column; gap: 8px; padding: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); z-index: 10001;
}
#start-menu[hidden] { display: none; }
.start-header { display: flex; gap: 10px; align-items: center; }
.start-header .logo { font-size: 30px; color: var(--accent); }
.start-header small { display: block; color: var(--muted); }
#start-search { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
#start-apps { list-style: none; margin: 0; padding: 0; overflow: auto; }
#start-apps button {
  width: 100%; display: flex; gap: 10px; align-items: center; padding: 8px; border: 0; border-radius: 8px; background: none; cursor: pointer; text-align: left;
}
#start-apps button:hover, #start-apps button:focus { background: var(--accent-soft); outline: none; }
#start-apps .ico { font-size: 22px; width: 28px; text-align: center; }
#start-apps small { display: block; color: var(--muted); }

/* Notificaciones */
#toasts { position: fixed; right: 12px; bottom: 60px; display: flex; flex-direction: column; gap: 8px; z-index: 10002; }
.toast {
  background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 320px; animation: pop .15s;
}

/* Elementos comunes de apps */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px;
  border-bottom: 1px solid var(--border); background: var(--panel); flex: none;
}
.toolbar button, .btn {
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); cursor: pointer;
}
.toolbar button:hover, .btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.statusbar { flex: none; padding: 4px 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; background: var(--panel-2); }

/* Diálogo modal dentro de una ventana */
.dialog-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 5; }
.dialog {
  width: min(420px, 92%); max-height: 90%; display: flex; flex-direction: column; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px; box-shadow: var(--shadow);
}
.dialog h3 { margin: 0; font-size: 15px; }
.dialog .file-list { border: 1px solid var(--border); border-radius: 6px; overflow: auto; min-height: 140px; max-height: 260px; }
.dialog .file-list div { padding: 6px 10px; cursor: pointer; }
.dialog .file-list div:hover { background: var(--panel-2); }
.dialog .file-list div.sel { background: var(--accent-soft); }
.dialog input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); }
.dialog .actions { display: flex; justify-content: flex-end; gap: 6px; }

/* Inicio de sesión */
#login { position: fixed; inset: 0; z-index: 30000; display: grid; place-items: center; background: var(--wallpaper); }
#login[hidden] { display: none; }
.login-card {
  width: min(340px, 92vw); display: flex; flex-direction: column; gap: 10px; padding: 28px;
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); text-align: center;
}
.login-card .logo { font-size: 44px; color: var(--accent); }
.login-card h1 { margin: 0; font-size: 24px; }
.login-card .sub { margin: 0 0 8px; color: var(--muted); }
.login-card input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.login-card .btn { padding: 10px; }
.login-card .link { border: 0; background: none; color: var(--accent); cursor: pointer; }
.login-card .error { margin: 0; color: #dc2626; font-size: 13px; }

/* Usuario en el menú Inicio */
.start-user { display: flex; align-items: center; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.start-user span { flex: 1; color: var(--muted); }
.start-user[hidden] { display: none; }
