/* ============================================================
   Kalendra · Sheet styles (print-exact, theme driven)
   All sizes in em -> scale with --k (autofit) and --fs (user)
   ============================================================ */
.ks{position:relative;overflow:hidden;font-family:var(--fb);color:var(--ink);font-size:calc(12.5px * var(--k) * var(--fs));line-height:1.28;background:linear-gradient(135deg,var(--pg) 0%,var(--pg2) 100%);-webkit-print-color-adjust:exact;print-color-adjust:exact;box-sizing:border-box;text-rendering:optimizeLegibility}
.ks *,.ks *::before,.ks *::after{box-sizing:border-box}
.ks-bg{position:absolute;inset:0;pointer-events:none}
.ks-bgimg{position:absolute;inset:0;background-size:cover;background-position:center}
.ks-orn{position:absolute;inset:0;color:var(--orn);opacity:var(--ornop)}
.ks-orn .orn{position:absolute;inset:0;width:100%;height:100%}
.ks-orn .orn-img{object-fit:cover}
.ks-orn .orn-greca{opacity:.16}
.ks-orn .orn-hojas{opacity:.55}
.ks-orn .orn-ondas{opacity:.22}
.ks-orn .orn-geo{opacity:.18}
.ks-orn .orn-puntos{opacity:.5}
.ks-orn .orn-lineas{opacity:.35}
.ks-orn .orn-serp{opacity:.35;width:55%;height:60%;top:auto;bottom:0}
.ks-orn .orn-esquinas{opacity:.9}
.ks-stk{position:absolute;inset:0;pointer-events:none;z-index:1}
.ks-stk-front{z-index:3}
.ks-sticker{position:absolute;pointer-events:none}
.ks-sticker img{width:100%;height:auto;display:block}
.ks-sticker.is-edit{pointer-events:auto;cursor:move;outline:1px dashed transparent}
.ks-sticker.is-edit:hover,.ks-sticker.is-sel{outline-color:#3b82f6}
.ks-handle{position:absolute;right:-7px;bottom:-7px;width:14px;height:14px;border-radius:50%;background:#3b82f6;border:2px solid #fff;cursor:nwse-resize;display:none}
.ks-del{position:absolute;right:-9px;top:-9px;width:20px;height:20px;border-radius:50%;background:#ef4444;color:#fff;font:700 14px/18px system-ui;text-align:center;font-style:normal;cursor:pointer;display:none;border:2px solid #fff}
.ks-sticker.is-edit:hover .ks-handle,.ks-sticker.is-edit:hover .ks-del,.ks-sticker.is-sel .ks-handle,.ks-sticker.is-sel .ks-del{display:block}

.ks-paper{position:absolute;inset:var(--margin);display:flex;flex-direction:column;z-index:2;padding:1.9em 2.1em 1.4em;background:var(--paper);border:var(--fw) solid var(--frame);border-radius:var(--rad);box-shadow:0 1.6em 3.6em rgba(0,0,0,.28),0 .2em .6em rgba(0,0,0,.12);overflow:hidden}

/* ---------- Header ---------- */
.ks-head{display:flex;align-items:center;gap:1.4em;flex:none;margin-bottom:1em;position:relative}
.ks-brand{display:flex;align-items:center;gap:.8em;min-width:0}
.ks-logo{height:calc(4.2em * var(--ls,1));width:auto;max-width:12em;object-fit:contain;display:block}
.ks-brand-name{font-family:var(--fh);font-weight:800;font-size:1.55em;letter-spacing:.02em;color:var(--ink);line-height:1;text-transform:uppercase}
.ks-brand-sub{font-size:.7em;letter-spacing:.22em;text-transform:uppercase;color:var(--acc);font-weight:600;margin-top:.3em}
.ks-brand-name:empty,.ks-brand-sub:empty{display:none}
.ks-titles{flex:1;min-width:0;text-align:right}
.ks-title{margin:0;font-family:var(--fh);font-weight:400;font-size:3.6em;line-height:.95;letter-spacing:.04em;color:var(--pri);white-space:nowrap}
.ks-title .t-acc{color:var(--acc);font-weight:700}
.ks-subtitle{font-size:1em;color:var(--muted);margin-top:.35em;letter-spacing:.04em}
.ks-subtitle:empty{display:none}
.ks-head-center{flex-direction:column;text-align:center;gap:.5em}
.ks-head-center .ks-titles{text-align:center}
.ks-head-center .ks-brand{justify-content:center}
.ks-head-left .ks-titles{text-align:left;order:2}
.ks-head-left .ks-brand{order:1}
.ks-head-stack{flex-direction:column;align-items:flex-start;gap:.6em}
.ks-head-stack .ks-titles{text-align:left}
.ks-brand2 .ks-logo{height:calc(3.6em * var(--ls,1))}
[contenteditable="true"]{outline:none;border-radius:4px;transition:box-shadow .15s}
[contenteditable="true"]:hover{box-shadow:0 0 0 1px rgba(59,130,246,.55)}
[contenteditable="true"]:focus{box-shadow:0 0 0 2px #3b82f6;background:rgba(59,130,246,.04)}
[contenteditable="true"]:empty::before{content:'Escribe aquí…';color:var(--muted);opacity:.6;font-style:italic;font-weight:400}
.ks-brand-name[contenteditable="true"]:empty,.ks-brand-sub[contenteditable="true"]:empty,.ks-subtitle[contenteditable="true"]:empty{display:block;min-width:6em}
.ks-brand-sub[contenteditable="true"]:empty::before{content:'Subtítulo de marca';}
.ks-brand-name[contenteditable="true"]:empty::before{content:'Nombre';}
.ks-subtitle[contenteditable="true"]:empty::before{content:'Subtítulo (opcional)'}

.ks-body{flex:1;min-height:0;display:flex;flex-direction:column;position:relative}
.ks-body>*{flex:1;min-height:0}
.ks-foot{flex:none;margin-top:.7em;font-size:.82em;color:var(--muted);min-height:1em}
.ks-foot[contenteditable="true"]:empty::before{content:'Pie de página (opcional)'}
.ks-pageno{position:absolute;right:1.4em;bottom:.6em;font-size:.72em;color:var(--muted);letter-spacing:.1em}
.ks-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--muted);font-size:1.2em;border:var(--lw) dashed var(--line);border-radius:calc(var(--rad) * .5);gap:.3em;cursor:default}
.ks-empty small{font-size:.75em;opacity:.8}

/* ---------- Highlights bar ---------- */
.ks-hlbar{flex:none;display:flex;justify-content:center;align-items:center;flex-wrap:wrap;gap:.4em 1.2em;margin-top:.8em;padding-top:.7em;border-top:var(--lw) solid var(--line);font-size:.86em;letter-spacing:.06em;color:var(--ink)}
.ks-hlbar i{width:.4em;height:.4em;border-radius:50%;background:var(--acc);display:inline-block}
.ks-hlbar b{color:var(--pri)}

/* ---------- Notes / efemérides ---------- */
.ks-notes{flex:none;margin-top:.9em;padding-top:.8em;border-top:var(--lw) solid var(--line);max-height:30%;display:flex;flex-direction:column}
.ks-notes-title{margin:0 0 .5em;font-family:var(--fh);font-size:1.05em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--ink)}
.ks-notes-body{column-count:var(--ncols);column-gap:2em;font-size:.86em;line-height:1.35;overflow:hidden;min-height:2em}
.ks-notes-body b,.ks-notes-body strong{color:var(--pri)}
.ks-notes-body p{margin:0 0 .3em}

/* ---------- Events ---------- */
.ke{position:relative;border-left:.28em solid var(--ec);padding:.15em 0 .2em .55em;margin-bottom:.45em;break-inside:avoid}
.ke-time{font-weight:700;color:var(--pri);font-size:.92em;letter-spacing:.01em}
.ke-title{font-weight:500;color:var(--ink)}
.ke-loc{font-size:.85em;color:var(--muted);margin-top:.1em}
.ke-loc::before{content:'⌖ ';color:var(--acc)}
.ke-desc{font-size:.86em;color:var(--muted);margin-top:.15em}
.ke-desc p{margin:0}
.ke-hl{background:var(--ecs);border-radius:0 .35em .35em 0}
.ke-mini{font-size:.82em;margin-bottom:.3em;padding:.08em 0 .1em .45em;border-left-width:.25em}
.ke-mini .ke-time{font-size:.9em}
.ke-mini .ke-title{line-height:1.15}
.ke-chip{display:inline-block;margin:0 .4em .3em 0;padding:.25em .7em;border:none;border-radius:1em;background:var(--ecs);color:var(--ink)}
.ke-chip .ke-time{display:inline;margin-right:.4em}
.ke-chip .ke-title{display:inline}
.ke-block{height:100%;margin:0;background:var(--ecs);border-radius:0 .4em .4em 0;padding:.3em .5em;overflow:hidden}
[data-event]{cursor:pointer}
[data-event]:hover{filter:brightness(.97);box-shadow:0 0 0 1px var(--ec)}

/* ---------- Month ---------- */
.km{display:flex;flex-direction:column}
.km-head{display:grid;grid-template-columns:repeat(var(--cols),1fr);flex:none;background:var(--headbg);border-radius:calc(var(--rad)*.4) calc(var(--rad)*.4) 0 0}
.km-dow{padding:.45em .6em;font-family:var(--fh);font-weight:700;text-transform:uppercase;letter-spacing:.12em;font-size:.86em;color:var(--headink);text-align:center}
.km-grid{flex:1;min-height:0;display:grid;grid-template-columns:repeat(var(--cols),1fr);grid-template-rows:repeat(var(--rows),minmax(0,1fr));border-top:var(--lw) solid var(--line);border-left:var(--lw) solid var(--line)}
.km-cell{border-right:var(--lw) solid var(--line);border-bottom:var(--lw) solid var(--line);padding:.3em .4em .2em;display:flex;flex-direction:column;min-height:0;overflow:hidden;background:var(--cell);position:relative}
.km-cell.is-wkend{background:var(--wkend)}
.km-cell.is-out{opacity:.35}
.km-cell.is-out .km-evs{display:none}
.km-num{flex:none;display:flex;justify-content:flex-end;font-family:var(--fh);font-size:1.25em;font-weight:500;color:var(--ink);line-height:1;margin-bottom:.2em}
.km-num span{min-width:1.7em;height:1.7em;display:inline-flex;align-items:center;justify-content:center;border-radius:1em}
.km-cell.is-today .km-num span{background:var(--today);color:var(--todayink);font-weight:700}
.km-evs{flex:1;min-height:0;overflow:hidden}
.km-hl{flex:none;align-self:stretch;margin:-.1em 0 .3em;background:var(--pri);color:var(--paper);border-radius:.5em;padding:.2em .4em;font-size:.78em;font-weight:600;text-align:center;line-height:1.15;box-shadow:0 .3em .8em rgba(0,0,0,.18)}
.km-cell[data-day]{cursor:cell}
.km-cell[data-day]:hover{box-shadow:inset 0 0 0 2px var(--prisoft)}

/* ---------- Week ---------- */
.kw{display:grid;grid-template-columns:repeat(var(--cols),minmax(0,1fr));gap:0}
.kw-col{display:flex;flex-direction:column;min-height:0;padding:0 .7em;border-left:var(--lw) solid var(--line)}
.kw-col:first-child{border-left:none}
.kw-dow{text-align:center;font-family:var(--fh);font-weight:700;text-transform:uppercase;letter-spacing:.1em;color:var(--headink);font-size:1.02em;padding:.2em 0 .1em;background:var(--headbg)}
.kw-dot{display:inline-block;width:.45em;height:.45em;border-radius:50%;background:var(--acc);vertical-align:middle}
.kw-col.is-today .kw-dow{color:var(--pri)}
.kw-num{text-align:right;font-family:var(--fh);font-weight:300;font-size:2.4em;color:var(--ink);line-height:1.1;margin-bottom:.25em;padding-bottom:.1em;border-bottom:var(--lw) solid var(--line)}
.kw-num span{display:inline-block;padding:0 .25em;border-radius:.4em}
.kw-col.is-today .kw-num span{background:var(--today);color:var(--todayink);font-weight:500}
.kw-evs{flex:1;min-height:0;overflow:hidden;padding-top:.3em}
.kw-col[data-day]{cursor:cell}
.kw-col[data-day]:hover{background:var(--prifaint)}

/* ---------- List / agenda ---------- */
.kl{display:flex;flex-direction:column;overflow:hidden}
.kl-row{display:grid;grid-template-columns:7.2em 1fr auto;gap:1.2em;align-items:center;padding:.9em .4em;border-bottom:var(--lw) solid var(--line);position:relative}
.kl-row.is-same{border-top:none;padding-top:.3em}
.kl-row:last-child{border-bottom:none}
.kl-date{display:flex;align-items:baseline;gap:.5em;justify-content:flex-end}
.kl-num{font-family:var(--fh);font-weight:300;font-size:3em;line-height:.9;color:var(--muted)}
.kl-dow{font-weight:800;text-transform:uppercase;font-size:.95em;letter-spacing:.06em;color:var(--pri);min-width:2.6em}
.kl-main{border-left:.28em solid var(--ec);padding-left:.8em;min-width:0}
.kl-title{font-size:1.25em;font-weight:500;color:var(--ink)}
.kl-loc{font-size:.9em;color:var(--muted);margin-top:.15em}
.kl-loc span{color:var(--acc)}
.kl-desc{font-size:.9em;color:var(--muted);margin-top:.2em}
.kl-desc p{margin:0}
.kl-time{font-weight:700;color:var(--pri);white-space:nowrap;font-size:1em;text-align:right}

/* ---------- Day ---------- */
.kd{display:flex;flex-direction:column}
.kd-all{flex:none;margin-bottom:.6em}
.kd-grid{flex:1;position:relative;margin-left:5.5em;border-left:var(--lw) solid var(--line);min-height:0}
.kd-hour{position:absolute;left:0;right:0;border-top:var(--lw) solid var(--line);height:0}
.kd-hour span{position:absolute;right:calc(100% + .6em);top:-.6em;font-size:.82em;color:var(--muted);white-space:nowrap}
.kd-events{position:absolute;inset:0 0 0 .4em}
.kd-ev{position:absolute;min-height:1.4em}

/* ---------- Year ---------- */
.ky{display:grid;grid-template-columns:repeat(4,1fr);grid-template-rows:repeat(3,minmax(0,1fr));gap:1em 1.6em}
.ks[style*="height"] .ky{align-content:stretch}
.ky-m{display:flex;flex-direction:column;min-height:0}
.ky-name{font-family:var(--fh);font-weight:700;text-transform:uppercase;letter-spacing:.12em;color:var(--pri);font-size:1.05em;padding-bottom:.25em;margin-bottom:.3em;border-bottom:var(--lw) solid var(--line)}
.ky-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:.12em;font-size:.86em;text-align:center;flex:1;align-content:start}
.ky-dow{font-weight:700;color:var(--muted);font-size:.85em}
.ky-d{padding:.18em 0;border-radius:.4em;color:var(--ink)}
.ky-d.has-ev{background:var(--accsoft);font-weight:700}
.ky-d.has-hl{background:var(--pri);color:var(--paper)}
.ky-d.is-today{box-shadow:inset 0 0 0 1.5px var(--today)}
.ky-d[data-day]{cursor:pointer}

/* ================= THEME PERSONALITIES ================= */
/* Guinda: wide headline, light weight, gold year */
.ks-t-guinda .ks-title{font-weight:400;letter-spacing:.06em}
.ks-t-guinda .km-num{justify-content:flex-end}
.ks-t-guinda .ks-brand-name{color:#3a2a2e}

/* Imperial: header band + gold double rule */
.ks-t-imperial .ks-paper{padding-top:0;box-shadow:0 0 0 .35em var(--paper),0 0 0 calc(.35em + 1px) var(--acc),0 2em 4em rgba(0,0,0,.45)}
.ks-t-imperial .ks-head{margin:0 -2.1em 1.1em;padding:1.1em 2.1em;background:var(--pri);color:#f5e6c4;border-bottom:.25em double var(--acc)}
.ks-t-imperial .ks-brand-name{color:#f5e6c4}
.ks-t-imperial .ks-title{color:#f5e6c4;font-style:italic}
.ks-t-imperial .ks-subtitle{color:#e8d2a6}
.ks-t-imperial .km-dow{color:#f5e6c4}
.ks-t-imperial .kw-dow{color:#f5e6c4;border-radius:.3em}
.ks-t-imperial .km-num,.ks-t-imperial .kw-num,.ks-t-imperial .kl-num{font-style:italic}
.ks-t-imperial .km-grid{border-color:var(--acc)}

/* Marfil: inner hairline frame + centered serif */
.ks-t-marfil .ks-paper{box-shadow:inset 0 0 0 .6em var(--paper),inset 0 0 0 calc(.6em + 1px) var(--acc),0 1.2em 3em rgba(80,60,30,.18);padding:2.4em 2.6em 1.6em}
.ks-t-marfil .ks-title{font-weight:500;font-size:4em;letter-spacing:.08em}
.ks-t-marfil .ks-title .t-acc{font-weight:600}
.ks-t-marfil .km-dow{font-family:var(--fb);font-weight:600;letter-spacing:.24em;font-size:.76em}
.ks-t-marfil .km-num{font-size:1.45em;font-weight:600}
.ks-t-marfil .kl-num{font-weight:500}

/* Ejecutivo: left accent strip, compact neo-grotesque */
.ks-t-ejecutivo .ks-paper{border-left:.55em solid var(--acc)}
.ks-t-ejecutivo .ks-title{font-weight:800;letter-spacing:-.02em;color:var(--ink);font-size:3.2em}
.ks-t-ejecutivo .ks-title .t-acc{color:var(--acc)}
.ks-t-ejecutivo .km-head{border-radius:.5em}
.ks-t-ejecutivo .km-grid{border:none;gap:.35em;margin-top:.35em}
.ks-t-ejecutivo .km-cell{border:var(--lw) solid var(--line);border-radius:.55em}
.ks-t-ejecutivo .km-num{justify-content:flex-start;font-weight:700;font-size:1.1em}
.ks-t-ejecutivo .kw-col{background:#f8f9fb;border:var(--lw) solid var(--line);border-radius:.7em;margin:0 .2em;padding-top:.5em}
.ks-t-ejecutivo .kw-dow{background:none}
.ks-t-ejecutivo .kw-num{font-weight:700;text-align:left}

/* Pacífico: rounded soft cells + wave orn */
.ks-t-pacifico .ks-title{font-weight:600;letter-spacing:.02em}
.ks-t-pacifico .km-grid{border:none;gap:.4em;margin-top:.3em}
.ks-t-pacifico .km-cell{border:none;border-radius:.9em;background:#eef4f9}
.ks-t-pacifico .km-cell.is-wkend{background:#e3edf6}
.ks-t-pacifico .km-num{justify-content:flex-start;font-weight:600}
.ks-t-pacifico .ke{border-left-width:.35em;border-radius:.2em}
.ks-t-pacifico .kw-col{border:none;background:#eef4f9;border-radius:1em;margin:0 .2em;padding-top:.6em}
.ks-t-pacifico .kw-num{border:none;font-weight:600}

/* Jade: botanical, serif numerals */
.ks-t-jade .ks-title{font-style:italic;font-weight:500}
.ks-t-jade .km-num{font-style:italic;font-weight:600}
.ks-t-jade .km-head{border-bottom:2px solid var(--acc)}
.ks-t-jade .kw-num{font-style:italic;font-weight:400}

/* Nórdico: bold black frame, oversize type, square */
.ks-t-nordico .ks-paper{box-shadow:none;border-width:calc(var(--fw) * 2)}
.ks-t-nordico .ks-title{font-weight:700;font-size:4.4em;letter-spacing:-.03em;color:var(--ink);text-transform:lowercase}
.ks-t-nordico .ks-title .t-acc{color:var(--acc)}
.ks-t-nordico .km-dow{text-align:left;letter-spacing:.04em;font-weight:500;text-transform:lowercase}
.ks-t-nordico .km-grid{border-left:none}
.ks-t-nordico .km-cell{border-right:none}
.ks-t-nordico .km-num{justify-content:flex-start;font-weight:600;font-size:1.5em}
.ks-t-nordico .kw-dow{text-transform:lowercase;text-align:left}
.ks-t-nordico .kw-num{text-align:left;font-weight:700}

/* Obsidiana: dark luxury */
.ks-t-obsidiana .ks-paper{box-shadow:0 0 0 1px rgba(212,175,55,.25),0 2em 5em rgba(0,0,0,.6)}
.ks-t-obsidiana .ks-title{color:#ece8e1}
.ks-t-obsidiana .ks-title .t-acc{color:var(--acc)}
.ks-t-obsidiana .ks-brand-name{color:#ece8e1}
.ks-t-obsidiana .km-hl{color:#111}
.ks-t-obsidiana .ky-d.has-hl{color:#111}

/* Terracota: chunky caps, agave accents */
.ks-t-terracota .ks-title{font-weight:700;letter-spacing:.1em}
.ks-t-terracota .ks-title .t-acc{color:var(--acc)}
.ks-t-terracota .km-head{background:var(--pri);border-radius:.5em .5em 0 0}
.ks-t-terracota .km-dow{color:#fbf3ea}
.ks-t-terracota .km-num{font-weight:700}
.ks-t-terracota .kw-dow{background:var(--pri);color:#fbf3ea;border-radius:.4em}

/* Aurora: gradient title, airy */
.ks-t-aurora .ks-title{color:var(--pri);font-weight:700}
.ks-t-aurora .ks-title .t-acc{color:var(--acc)}
.ks-t-aurora .ks-head::after{content:'';position:absolute;left:0;right:0;bottom:-.5em;height:.22em;border-radius:1em;background:linear-gradient(90deg,var(--pri),var(--acc))}
.ks-t-aurora .km-grid{border:none;gap:.35em}
.ks-t-aurora .km-cell{border:var(--lw) solid var(--line);border-radius:.9em}
.ks-t-aurora .km-cell.is-today{border-color:var(--acc)}
.ks-t-aurora .km-num{justify-content:flex-start;font-weight:700}
.ks-t-aurora .kw-num{font-weight:600}

.ks.is-compact .ks-paper{padding:1.2em 1.4em 1em}
.ks.is-compact .ks-head{margin-bottom:.6em}
.ks.is-compact .ks-title{font-size:2.8em}

/* Portrait adjustments */
.ks-portrait .ks-title{font-size:3em}
.ks-portrait .ks-head{flex-wrap:wrap}
.ks-portrait .ky{grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(4,minmax(0,1fr))}
.ks-portrait .kw{grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-rows:minmax(0,1fr);gap:.8em}
.ks-portrait .kw-col{border:var(--lw) solid var(--line);border-radius:calc(var(--rad)*.4);padding-top:.4em}
.ks-portrait .kw-num{font-size:1.8em}
