:root {
  --gap: 0px; --radius: 28px; --pad: 0px; --blur: 28px; --glass: .16; --accent: #0a84ff;
  --fs: 1; --text: #fff; --text-2: rgba(255,255,255,.72); --text-3: rgba(255,255,255,.48);
  --line: rgba(255,255,255,.14);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0d14; }
body {
  font-family: -apple-system, "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text); -webkit-font-smoothing: antialiased; font-size: calc(16px * var(--fs));
  user-select: none;
}
body.nocursor, body.nocursor * { cursor: none !important; }

/* ---------- fondos ---------- */
#bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; background: var(--bg-base); background-size: cover; background-position: center; }
.blob { position: absolute; border-radius: 50%; filter: blur(140px); opacity: .55; }
.b1 { width: 55vw; height: 55vw; left: -10vw; top: -15vw; background: var(--c1); }
.b2 { width: 45vw; height: 45vw; right: -8vw; top: 5vh; background: var(--c2); }
.b3 { width: 50vw; height: 50vw; left: 25vw; bottom: -25vw; background: var(--c3); }
.b4 { width: 30vw; height: 30vw; right: 15vw; bottom: 5vh; background: var(--c4); }
body.animate .b1 { animation: drift1 70s ease-in-out infinite alternate; }
body.animate .b2 { animation: drift2 90s ease-in-out infinite alternate; }
body.animate .b3 { animation: drift1 80s ease-in-out infinite alternate-reverse; }
body.animate .b4 { animation: drift2 60s ease-in-out infinite alternate-reverse; }
@keyframes drift1 { to { transform: translate(12vw, 8vh) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-10vw, 12vh) scale(.9); } }

body[data-theme=aurora]   { --bg-base: #0d1026; --c1: #5b2bd6; --c2: #0fb5c9; --c3: #1d4fd8; --c4: #e04891; }
body[data-theme=ocean]    { --bg-base: #031627; --c1: #0066cc; --c2: #00b3a4; --c3: #1e3a8a; --c4: #38bdf8; }
body[data-theme=sunset]   { --bg-base: #1f0c1e; --c1: #ff6b35; --c2: #d6246e; --c3: #7b2cbf; --c4: #ffb703; }
body[data-theme=forest]   { --bg-base: #08160f; --c1: #16a34a; --c2: #0f766e; --c3: #65a30d; --c4: #134e4a; }
body[data-theme=graphite] { --bg-base: #121214; --c1: #3a3a42; --c2: #5c5c66; --c3: #26262c; --c4: #7a7a85; }
body[data-theme=midnight] { --bg-base: #000000; --c1: #111133; --c2: #1a0f2e; --c3: #0a1a2a; --c4: #221133; }
body[data-theme=custom] .blob { display: none; }

/* ---------- grid ---------- */
#grid {
  position: relative; z-index: 1; width: 100vw; height: 100vh; padding: var(--pad);
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows), 1fr);
}
/* Con gap 0 las tarjetas se funden en un unico bloque: solo se redondean las esquinas exteriores */
#grid.joined { border-radius: 0; }
#grid.joined.padded { border-radius: var(--radius); overflow: hidden; }

/* ---------- liquid glass ---------- */
.w {
  position: relative; overflow: hidden; min-width: 0; min-height: 0;
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(14,16,28,.22), rgba(14,16,28,.22)),
    linear-gradient(155deg, rgba(255,255,255,calc(var(--glass) + .10)) 0%, rgba(255,255,255,var(--glass)) 40%, rgba(255,255,255,calc(var(--glass) * .5)) 100%);
  backdrop-filter: blur(var(--blur)) saturate(190%) brightness(1.05);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(190%) brightness(1.05);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.55),
    inset 1px 0 0 rgba(255,255,255,.18),
    inset 0 -1px 0 rgba(255,255,255,.08),
    inset -1px 0 0 rgba(255,255,255,.06),
    0 10px 40px rgba(0,0,0,.22);
  padding: calc(24px * var(--fs));
  display: flex; flex-direction: column;
  transition: opacity .4s;
}
/* brillo especular superior */
.w::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background:
    radial-gradient(120% 60% at 15% -10%, rgba(255,255,255,.28), transparent 55%),
    radial-gradient(80% 50% at 100% 110%, rgba(255,255,255,.08), transparent 60%);
}
/* borde refractado */
.w::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; padding: 1px;
  background: linear-gradient(135deg, rgba(255,255,255,.6), rgba(255,255,255,.05) 35%, rgba(255,255,255,.02) 65%, rgba(255,255,255,.35));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
#grid.joined .w { border-radius: 0; box-shadow: inset 0 0 0 .5px rgba(255,255,255,.22); }
#grid.joined .w::before { background: radial-gradient(140% 70% at 0% -20%, rgba(255,255,255,.14), transparent 60%); }
#grid.joined .w::after { background: none; }
#grid.joined .w.tl { border-top-left-radius: var(--radius); }
#grid.joined .w.tr { border-top-right-radius: var(--radius); }
#grid.joined .w.bl { border-bottom-left-radius: var(--radius); }
#grid.joined .w.br { border-bottom-right-radius: var(--radius); }

.w > * { position: relative; z-index: 1; }
.wt { font-size: .78em; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2);
  height: 1.6em; line-height: 1.6em; margin-bottom: .9em; padding-bottom: .9em; box-sizing: content-box;
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .5em; flex-shrink: 0; white-space: nowrap; overflow: hidden; }
.wt .count { margin-left: auto; line-height: 1.4; background: rgba(255,255,255,.16); border-radius: 99px; padding: .1em .6em; letter-spacing: 0; }
.fill { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.center { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- reloj ---------- */
.clock-digital { font-weight: 200; letter-spacing: -.04em; line-height: .9; font-size: var(--big); white-space: nowrap; }
.clock-digital .sec { font-size: .35em; font-weight: 300; color: var(--text-2); letter-spacing: 0; margin-left: .15em; }
.clock-digital .ampm { font-size: .25em; font-weight: 500; color: var(--text-2); margin-left: .2em; }
.clock-minimal { font-weight: 700; letter-spacing: -.05em; line-height: .85; font-size: var(--big); }
.clock-sub { margin-top: .35em; color: var(--text-2); font-size: 1.1em; }
.clock-sub::first-letter, .date-month::first-letter, .cal-title::first-letter { text-transform: uppercase; }
.analog { width: min(92%, 92cqh); aspect-ratio: 1; }
.analog .face { fill: rgba(255,255,255,.06); stroke: rgba(255,255,255,.3); stroke-width: 1; }
.analog .tick { stroke: rgba(255,255,255,.55); stroke-linecap: round; }
.analog .hand { stroke: #fff; stroke-linecap: round; }
.analog .hand.s { stroke: var(--accent); }

/* ---------- fecha ---------- */
.date-day { font-size: 1.05em; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; filter: brightness(1.4); }
.date-num { font-size: var(--big); font-weight: 200; line-height: 1; letter-spacing: -.04em; }
.date-month { font-size: 1.2em; color: var(--text-2); }

/* ---------- tiempo ---------- */
.wx-now { flex: 1; display: flex; align-items: center; gap: 1.2em; min-height: 0; }
.wx-now .ico { width: var(--ico); height: var(--ico); flex-shrink: 0; }
.wx-temp { font-size: var(--big); font-weight: 200; line-height: .9; letter-spacing: -.04em; }
.wx-desc { font-size: 1.25em; margin-top: .25em; }
.wx-meta { display: flex; gap: 1.2em; flex-wrap: wrap; margin-top: .6em; color: var(--text-2); font-size: .95em; }
.wx-loc { font-size: 1.1em; font-weight: 600; }
.week { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .3em; min-height: 0; }
.week.rows { grid-auto-flow: row; grid-auto-rows: 1fr; }
.day { display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; border-radius: 16px; padding: .3em .1em; min-height: 0; }
.day.today { background: rgba(255,255,255,.12); }
.day .ico { width: 3.6em; height: 3.6em; }
.day .dn { font-weight: 600; text-transform: capitalize; }
.day .hi { font-weight: 600; } .day .lo { color: var(--text-3); }
.day .pp { font-size: .78em; color: #8fd3ff; min-height: 1em; }
.week.rows .day { flex-direction: row; justify-content: space-between; padding: 0 .6em; }
.week.rows .day .dn { width: 4em; text-align: left; }
.week.rows .day .ico { width: 1.8em; height: 1.8em; }
.bar { flex: 1; height: 5px; border-radius: 3px; background: rgba(255,255,255,.12); margin: 0 .6em; position: relative; }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, #5ac8fa, #ffd60a, #ff9f0a); }
.hours { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; min-height: 0; }
.hour { display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; }
.hour .ico { width: 2em; height: 2em; }
.hour .t { font-weight: 600; font-size: 1.1em; }
svg.ico * { vector-effect: non-scaling-stroke; }

/* ---------- tareas ---------- */
.tasks { flex: 1; overflow: hidden; display: flex; flex-direction: column; gap: .15em;
  -webkit-mask-image: linear-gradient(#000 85%, transparent); mask-image: linear-gradient(#000 85%, transparent); }
.task { display: flex; align-items: flex-start; gap: .75em; padding: .55em 0; border-bottom: 1px solid var(--line); font-size: 1.12em; line-height: 1.3; }
.task:last-child { border-bottom: 0; }
.chk { width: 1.25em; height: 1.25em; flex-shrink: 0; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); margin-top: .05em; display: grid; place-items: center; }
.task.high .chk { border-color: #ff6961; }
.task.done .chk { background: var(--accent); border-color: var(--accent); }
.task.done .chk::after { content: ""; width: .35em; height: .6em; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.task.done .tx { color: var(--text-3); text-decoration: line-through; }
.task .meta { font-size: .72em; color: var(--text-3); margin-top: .15em; }
.task .meta .late { color: #ff6961; }
.empty { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: .3em; color: var(--text-3); text-align: center; }

/* ---------- noticias ---------- */
.news { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.news-hero { display: flex; gap: 1.1em; align-items: stretch; flex-shrink: 0; margin-bottom: .8em; animation: fade .8s; }
.news-hero img { width: 34%; max-height: 9em; object-fit: cover; border-radius: 16px; flex-shrink: 0; }
.news-hero h3 { font-size: 1.45em; font-weight: 600; line-height: 1.2; }
.news-src { font-size: .78em; font-weight: 600; color: var(--accent); filter: brightness(1.5); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .35em; }
.news-list { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.news-item { padding: .5em 0; border-top: 1px solid var(--line); font-size: 1em; line-height: 1.3; display: flex; gap: .8em; }
.news-item .ago { color: var(--text-3); font-size: .85em; flex-shrink: 0; min-width: 3.2em; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

/* ---------- calendario ---------- */
.cal { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; text-align: center; align-items: center; min-height: 0; }
.cal .h { color: var(--text-3); font-size: .8em; font-weight: 600; }
.cal .d { font-size: 1.05em; justify-self: center; width: 2em; height: 2em; display: grid; place-items: center; border-radius: 50%; }
.cal .o { color: var(--text-3); opacity: .5; }
.cal .we { color: var(--text-2); }
.cal .now { background: var(--accent); color: #fff; font-weight: 700; box-shadow: 0 0 18px var(--accent); }
.cal-title { font-size: 1.3em; font-weight: 600; margin-bottom: .3em; }

/* ---------- otros ---------- */
.note { flex: 1; font-size: 1.35em; line-height: 1.4; white-space: pre-wrap; overflow: hidden; }
.sun-row { display: flex; justify-content: space-around; flex: 1; align-items: center; }
.sun-len { text-align: center; }
.sun-row div { text-align: center; }
.sun-row b { display: block; font-size: 1.7em; font-weight: 300; }
.sun-row .ico { width: 2.2em; height: 2.2em; }
.wc { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; }
.wc-row { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); padding: .35em 0; }
.wc-row:last-child { border: 0; }
.wc-row b { font-size: 1.8em; font-weight: 300; }
.sys { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: .5em 1.2em; align-content: center; }
.sys .k { color: var(--text-3); font-size: .8em; text-transform: uppercase; letter-spacing: .06em; }
.sys .v { font-size: 1.5em; font-weight: 300; }
.meter { height: 4px; background: rgba(255,255,255,.12); border-radius: 2px; margin-top: .3em; } .meter i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.quote { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.quote q { font-size: 1.35em; line-height: 1.35; font-weight: 300; font-style: italic; }
.quote span { margin-top: .6em; color: var(--text-2); }
.cd-num { display: flex; gap: .8em; justify-content: center; }
.cd-num div { text-align: center; } .cd-num b { display: block; font-size: var(--big); font-weight: 200; line-height: 1; }
.cd-num small { color: var(--text-3); text-transform: uppercase; font-size: .75em; letter-spacing: .08em; }

#dim { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 10; transition: opacity 2s; }
#offline { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 11; padding: .5em 1.2em; border-radius: 99px;
  background: rgba(255,59,48,.35); backdrop-filter: blur(20px); font-size: .9em; }

/* ---------- notas ---------- */
.notes { flex: 1; min-height: 0; overflow: hidden; display: grid; gap: .6em;
  grid-template-columns: repeat(auto-fill, minmax(11em, 1fr)); grid-auto-rows: minmax(5.5em, auto); align-content: start;
  -webkit-mask-image: linear-gradient(#000 88%, transparent); mask-image: linear-gradient(#000 88%, transparent); }
.nc { border-radius: 18px; padding: .75em .9em; overflow: hidden; background: rgba(255,255,255,.10);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), inset 0 0 0 1px rgba(255,255,255,.10); display: flex; flex-direction: column; gap: .3em; }
.nc .nt { font-weight: 600; font-size: 1.02em; display: flex; align-items: center; gap: .35em; }
.nc .nx { font-size: .92em; line-height: 1.35; color: var(--text-2); white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.nc .pin { width: .9em; height: .9em; flex-shrink: 0; opacity: .8; vertical-align: -.1em; margin-right: .2em; }
.c-yellow { background: linear-gradient(160deg, rgba(255,214,10,.38), rgba(255,214,10,.16)); }
.c-blue   { background: linear-gradient(160deg, rgba(10,132,255,.40), rgba(10,132,255,.16)); }
.c-green  { background: linear-gradient(160deg, rgba(48,209,88,.38), rgba(48,209,88,.14)); }
.c-pink   { background: linear-gradient(160deg, rgba(255,55,95,.38), rgba(255,55,95,.14)); }
.c-purple { background: linear-gradient(160deg, rgba(191,90,242,.40), rgba(191,90,242,.16)); }
.c-orange { background: linear-gradient(160deg, rgba(255,159,10,.40), rgba(255,159,10,.16)); }

/* ---------- barra de ventana oculta (solo en la Raspberry) ---------- */
#hot { position: fixed; top: 0; left: 0; right: 0; height: 6px; z-index: 30; display: none; }
#winbar { position: fixed; top: 12px; right: 12px; z-index: 31; display: none; gap: 6px; padding: 6px; border-radius: 99px;
  background: rgba(30,32,48,.45); backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), inset 0 0 0 1px rgba(255,255,255,.14), 0 10px 30px rgba(0,0,0,.35);
  transform: translateY(-140%); opacity: 0; transition: transform .35s cubic-bezier(.2,.9,.3,1.2), opacity .25s; }
body.local #hot, body.local #winbar { display: flex; }
#winbar.show { transform: none; opacity: 1; }
#winbar button { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); display: grid; place-items: center; cursor: pointer !important; transition: background .15s, transform .15s; }
#winbar button:hover { background: rgba(255,255,255,.26); transform: scale(1.06); }
#winbar button.close:hover { background: #ff453a; }
#winbar svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
body.cursor-idle, body.cursor-idle * { cursor: none !important; }
