
/* ══ SHARED WIDGETS — SELF-THEMING ════════════════════════════════════════
   These widgets previously inherited colours from whatever tokens the host
   page happened to define (--bg-card / --card / --sp-lift ...). On pages that
   defined none of them, or defined a LIGHT surface while the text token stayed
   light, the result was light-on-light and unreadable.

   They now carry their own palette, switched purely off <html data-theme>.
   Only the accent is taken from the page, and even that has a hard fallback.
   ══════════════════════════════════════════════════════════════════════════ */
.tk-w{
  --tkc:#1b6bf5;                 /* overwritten inline by the accent picker */
  --tkbg:#141b2d; --tkbg2:#1b2540; --tkln:rgba(255,255,255,.12);
  --tktx:#f2f5fc; --tkmu:#9fb0cc;
  color-scheme:dark;
}
html[data-theme="light"] .tk-w{
  --tkbg:#ffffff; --tkbg2:#f1f4fa; --tkln:rgba(15,23,42,.14);
  --tktx:#0f1729; --tkmu:#5b6a86;
  color-scheme:light;
}
.tk-w,.tk-w *{box-sizing:border-box}
.tk-w button{font-family:inherit}

.tk-fabs{position:fixed;right:16px;bottom:16px;z-index:2147483000;
  display:flex;flex-direction:column;gap:10px;align-items:flex-end}
.tk-fab{display:inline-flex;align-items:center;gap:8px;padding:10px 14px;border-radius:13px;cursor:pointer;
  background:var(--tkbg);border:1px solid var(--tkln);color:var(--tktx);
  font-size:.78rem;font-weight:700;box-shadow:0 12px 30px -10px rgba(0,0,0,.55)}
.tk-fab i{color:var(--tkc)}
.tk-fab-bot{width:52px;height:52px;padding:0;border-radius:50%;justify-content:center;
  background:var(--tkc);color:#fff;font-size:1.05rem;position:relative;border:0}
.tk-fab-bot i{color:#fff}
.tk-fab-bot::after{content:"";position:absolute;top:2px;right:2px;width:11px;height:11px;
  border-radius:50%;background:#22c55e;border:2px solid var(--tkbg)}

.tk-pop,.tk-bot{position:fixed;right:16px;bottom:80px;z-index:2147483001;
  background:var(--tkbg);border:1px solid var(--tkln);color:var(--tktx);
  box-shadow:0 26px 60px -14px rgba(0,0,0,.65)}
.tk-pop{width:290px;max-height:calc(100vh - 110px);overflow-y:auto;border-radius:18px;padding:16px}
.tk-pop[hidden],.tk-ov[hidden],.tk-bot[hidden]{display:none!important}
.tk-hd{display:flex;align-items:center;justify-content:space-between;margin-bottom:14px}
.tk-hd-t{font-size:.92rem;font-weight:800;color:var(--tktx)}
.tk-x{background:none;border:0;color:var(--tkmu);cursor:pointer;font-size:1rem;padding:3px;line-height:1}
.tk-x:hover{color:var(--tktx)}
.tk-gl{font-size:.7rem;font-weight:700;color:var(--tkmu);margin-bottom:8px}
.tk-modes{display:grid;grid-template-columns:1fr 1fr;gap:5px;padding:4px;border-radius:12px;
  background:var(--tkbg2);border:1px solid var(--tkln);margin-bottom:16px}
.tk-mode{padding:9px 6px;border:0;border-radius:9px;cursor:pointer;background:transparent;
  color:var(--tkmu);font-size:.76rem;font-weight:700;
  display:flex;align-items:center;justify-content:center;gap:6px}
.tk-mode:hover{color:var(--tktx)}
.tk-mode[aria-pressed="true"]{background:var(--tkc);color:#fff}
.tk-sw-row{display:grid;grid-template-columns:repeat(8,1fr);gap:7px;margin-bottom:16px}
.tk-sw{width:100%;aspect-ratio:1;border-radius:50%;cursor:pointer;border:2.5px solid transparent;padding:0;
  box-shadow:inset 0 0 0 1px rgba(0,0,0,.22)}
.tk-sw[aria-checked="true"]{border-color:var(--tktx)}
.tk-cust{display:flex;gap:8px;align-items:center;margin-bottom:13px}
.tk-cust input[type=color]{width:42px;height:38px;border:1px solid var(--tkln);border-radius:10px;
  background:var(--tkbg2);cursor:pointer;padding:3px;flex-shrink:0}
.tk-hex{flex:1;min-width:0;padding:10px 11px;border-radius:10px;background:var(--tkbg2);
  border:1.5px solid var(--tkln);color:var(--tktx);
  font-family:ui-monospace,monospace;font-size:.78rem;outline:none}
.tk-hex:focus{border-color:var(--tkc)}
.tk-btn{width:100%;padding:11px;border-radius:11px;cursor:pointer;background:var(--tkbg2);
  border:1px solid var(--tkln);color:var(--tktx);font-size:.78rem;font-weight:700;
  display:flex;align-items:center;justify-content:center;gap:7px}
.tk-btn:hover{border-color:var(--tkc);color:var(--tkc)}

/* Assistant */
.tk-bot{width:352px;height:min(470px,calc(100vh - 110px));border-radius:19px;
  display:flex;flex-direction:column;overflow:hidden}
.tk-bot-hd{padding:13px 15px;border-bottom:1px solid var(--tkln);display:flex;align-items:center;gap:10px;
  background:var(--tkbg2);flex-shrink:0}
.tk-av{width:33px;height:33px;border-radius:50%;background:var(--tkc);color:#fff;
  display:grid;place-items:center;font-size:.82rem;flex-shrink:0}
.tk-bot-t{font-size:.83rem;font-weight:800;line-height:1.2;color:var(--tktx)}
.tk-bot-s{font-size:.66rem;color:#22c55e;font-weight:700;margin-top:1px}
.tk-body{flex:1;overflow-y:auto;padding:15px;display:flex;flex-direction:column;gap:10px;
  background:var(--tkbg)}
.tk-msg{max-width:86%;padding:10px 12px;border-radius:14px;font-size:.8rem;line-height:1.55;font-weight:500}
.tk-msg.b{background:var(--tkbg2);color:var(--tktx);border-bottom-left-radius:5px;align-self:flex-start}
.tk-msg.u{background:var(--tkc);color:#fff;border-bottom-right-radius:5px;align-self:flex-end}
.tk-msg a{color:var(--tkc);font-weight:700}
.tk-msg.u a{color:#fff;text-decoration:underline}
.tk-msg b{font-weight:800}
.tk-chips{display:flex;flex-wrap:wrap;gap:6px;padding:0 15px 10px;background:var(--tkbg);flex-shrink:0}
.tk-chip{padding:6px 10px;border-radius:99px;cursor:pointer;background:transparent;border:1px solid var(--tkln);
  color:var(--tkmu);font-size:.69rem;font-weight:700}
.tk-chip:hover{border-color:var(--tkc);color:var(--tkc)}
.tk-in{display:flex;gap:7px;padding:11px;border-top:1px solid var(--tkln);background:var(--tkbg);flex-shrink:0}
.tk-in input{flex:1;min-width:0;padding:10px 12px;border-radius:11px;font-size:.8rem;outline:none;
  background:var(--tkbg2);border:1.5px solid var(--tkln);color:var(--tktx);font-family:inherit}
.tk-in input::placeholder{color:var(--tkmu)}
.tk-in input:focus{border-color:var(--tkc)}
.tk-in button{width:38px;flex-shrink:0;border:0;border-radius:11px;cursor:pointer;background:var(--tkc);color:#fff}

/* Modal: About + release notes combined */
.tk-ov{position:fixed;inset:0;z-index:2147483100;background:rgba(3,6,15,.76);
  -webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);
  display:grid;place-items:center;padding:16px}
.tk-modal{width:min(580px,100%);max-height:86vh;overflow-y:auto;background:var(--tkbg);color:var(--tktx);
  border:1px solid var(--tkln);border-radius:21px;padding:26px}
.tk-pill{display:inline-block;background:var(--tkbg2);color:var(--tkc);font-size:.66rem;
  font-weight:800;padding:5px 11px;border-radius:99px;margin-bottom:10px;letter-spacing:.05em}
.tk-modal h3{font-size:1.3rem;font-weight:900;letter-spacing:-.02em;margin:0;color:var(--tktx)}
.tk-modal p.tk-lead{font-size:.83rem;color:var(--tkmu);margin:7px 0 0;line-height:1.6;font-weight:500}
.tk-vtabs{display:flex;gap:6px;margin:16px 0 4px;flex-wrap:wrap}
.tk-vtab{padding:7px 13px;border-radius:99px;cursor:pointer;background:transparent;border:1.5px solid var(--tkln);
  color:var(--tkmu);font-size:.73rem;font-weight:800}
.tk-vtab:hover{color:var(--tktx)}
.tk-vtab.on{background:var(--tkc);border-color:var(--tkc);color:#fff}
.tk-vmeta{display:flex;align-items:center;gap:7px;font-size:.69rem;font-weight:700;color:var(--tkmu);margin:14px 0 2px}
.tk-vdot{width:8px;height:8px;border-radius:50%;background:var(--tkmu)}
.tk-vdot.now{background:#22c55e;box-shadow:0 0 7px #22c55e}
.tk-nlist{margin-top:14px;display:flex;flex-direction:column;gap:12px}
.tk-nitem{display:flex;gap:11px;align-items:flex-start}
.tk-nico{width:30px;height:30px;border-radius:9px;flex-shrink:0;display:grid;place-items:center;
  background:var(--tkbg2);color:var(--tkc);font-size:.74rem}
.tk-nt{font-size:.84rem;font-weight:800;color:var(--tktx)}
.tk-nd{font-size:.77rem;color:var(--tkmu);margin-top:3px;line-height:1.55;font-weight:500}
.tk-done{width:100%;margin-top:20px;padding:13px;border:0;border-radius:13px;cursor:pointer;
  background:var(--tkc);color:#fff;font-size:.88rem;font-weight:800}


/* ── OFFLINE CACHING INDICATOR ──────────────────────────────────────────────
   Mirrors the badge attendance.php already shows, but driven by the service
   worker so it can appear on every page. */
.tk-status-dock{flex:0 0 auto;min-width:0;padding:0 16px 6px;display:flex;align-items:center;}
.tk-cache{
  position:static !important; max-width:100%; min-width:0;
  display:inline-flex; align-items:center; gap:8px;
  padding:4px 10px; border-radius:99px;
  background:var(--tkbg); border:1px solid var(--tkln); color:var(--tktx);
  font-size:.72rem; font-weight:700; letter-spacing:.02em;
  box-shadow:none;
  transition:opacity .3s ease;
}
.tk-cache[hidden]{display:none!important}
.tk-cache{cursor:default}
.tk-cache small{opacity:.7;font-weight:600}
.tk-cache i{color:var(--tkc)}
.tk-cache.is-done i{color:#22c55e}
.tk-cache.is-off i{color:#f59e0b}
.tk-cache span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;}
@media (max-width:600px){ .tk-status-dock{padding:0 12px 6px;} .tk-cache{font-size:.68rem; padding:4px 8px;} }

@media (max-width:600px){
  .tk-fabs{right:12px;bottom:12px;gap:8px}
  .tk-fab span{display:none}
  .tk-fab{padding:0;width:46px;height:46px;border-radius:50%;justify-content:center}
  .tk-fab-bot{width:50px;height:50px}
  .tk-bot{right:8px;left:8px;bottom:74px;width:auto;height:min(70vh,calc(100vh - 100px))}
  .tk-pop{right:8px;left:8px;bottom:74px;width:auto}
  .tk-modal{padding:20px 17px;border-radius:17px}
}
@media print{.tk-w{display:none!important}}

/* Release history: keep the close action available with the expanded version list. */
#tkNotesOv > .tk-modal{max-width:580px;display:flex;flex-direction:column;overflow:hidden!important;min-height:0}
#tkNotesOv .tk-release-content{min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}
#tkNotesOv .tk-done{flex-shrink:0;margin-top:12px}
