/* ============================================================
   HUMAN DATA LEAD LAB — feature layer styles
   Tutor panel · notes scratchpad · track search · progress controls
   Ported from the IBM track widgets, recolored to the lab's
   cyan/violet accent. Uses the lab stylesheet's variables.
   ============================================================ */
:root {
  --hdl-grad: linear-gradient(135deg, #22d3ee, #818cf8);
  --hdl-ink: #04121a;
  --hdl-radius: 16px;
  /* Fallbacks so the widgets also render on pages (like the dashboard)
     that don't load the lab's main stylesheet. A page that does load it
     re-declares these tokens and wins. */
  --bg-primary: #0f1117;
  --bg-secondary: #161822;
  --bg-card: #1c1f2e;
  --bg-code: #1a1d2e;
  --bg-highlight: #232740;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-heading: #f1f5f9;
  --accent-cyan: #22d3ee;
  --accent-violet: #818cf8;
  --accent-yellow: #fbbf24;
  --accent-red: #f87171;
  --border-subtle: #2a2d3e;
  --border-card: #2e3148;
}

/* ---------------- PAGE TUTOR ---------------- */
#dvp-tutor { position: fixed; right: 20px; bottom: 20px; z-index: 200; font-size: 15px; }

.tut-fab {
  display: inline-flex; align-items: center; gap: .55rem;
  background: var(--hdl-grad); color: var(--hdl-ink); border: none;
  border-radius: 100px; padding: .7rem 1.1rem .7rem .8rem;
  font-family: inherit; font-size: .84rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
  transition: transform .2s cubic-bezier(.22,1,.36,1), box-shadow .2s, opacity .2s;
}
.tut-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(0,0,0,.55); }
.tut-fab-mark {
  width: 20px; height: 20px; border-radius: 50%; background: rgba(4,18,26,.22);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem;
}
#dvp-tutor.is-open .tut-fab { opacity: 0; pointer-events: none; }

.tut-panel {
  position: absolute; right: 0; bottom: 0; width: min(420px, calc(100vw - 40px));
  height: min(560px, calc(100vh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg-secondary); border: 1px solid var(--border-card);
  border-radius: var(--hdl-radius); box-shadow: 0 24px 60px rgba(0,0,0,.6);
  animation: tut-in .26s cubic-bezier(.22,1,.36,1);
}
.tut-panel[hidden] { display: none; }
@keyframes tut-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.tut-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1rem .85rem 1.1rem; border-bottom: 1px solid var(--border-subtle); }
.tut-eyebrow { font-size: .6rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-cyan); }
.tut-mode { color: var(--accent-violet); }
.tut-title { font-size: .92rem; font-weight: 700; color: var(--text-heading); }
.tut-close { background: none; border: none; color: var(--text-muted); font-size: .9rem; cursor: pointer; padding: .3rem .4rem; border-radius: 6px; }
.tut-close:hover { color: var(--text-heading); background: var(--bg-highlight); }

.tut-log { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .8rem; }
.tut-empty { color: var(--text-muted); font-size: .86rem; }
.tut-empty p { margin-bottom: .8rem; }
.tut-suggest { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }
.tut-chip {
  background: var(--bg-card); border: 1px solid var(--border-card); color: var(--text-secondary);
  border-radius: 100px; padding: .35rem .8rem; font-family: inherit; font-size: .76rem;
  cursor: pointer; text-align: left; transition: border-color .2s, color .2s;
}
.tut-chip:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.tut-chip-primary { border-color: rgba(34,211,238,.45); color: var(--accent-cyan); font-weight: 700; }

.tut-msg { font-size: .88rem; line-height: 1.6; }
.tut-msg p { margin: 0 0 .6rem; }
.tut-msg p:last-child { margin-bottom: 0; }
.tut-msg ul { margin: .3rem 0 .6rem 1.1rem; }
.tut-msg li { margin-bottom: .25rem; }
.tut-msg pre { margin: .5rem 0; padding: .7rem .85rem; font-size: .78rem; border-radius: 8px; background: var(--bg-code); overflow-x: auto; }
.tut-msg code { font-size: .8rem; }
.tut-you {
  align-self: flex-end; max-width: 85%; background: var(--bg-highlight);
  border: 1px solid var(--border-card); border-radius: 12px 12px 3px 12px; padding: .55rem .8rem;
  color: var(--text-heading);
}
.tut-ai { align-self: flex-start; max-width: 100%; color: var(--text-primary); border-left: 2px solid rgba(34,211,238,.35); padding-left: .8rem; }
.tut-err { color: var(--accent-red); }

.tut-dots { display: inline-flex; gap: 4px; align-items: center; height: 1.2rem; }
.tut-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-cyan); animation: tut-blink 1.2s ease-in-out infinite; }
.tut-dots i:nth-child(2) { animation-delay: .18s; }
.tut-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes tut-blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

.tut-form { display: flex; gap: .5rem; align-items: flex-end; padding: .75rem .9rem .9rem; border-top: 1px solid var(--border-subtle); }
.tut-input {
  flex: 1; resize: none; background: var(--bg-primary); border: 1px solid var(--border-card);
  border-radius: 10px; padding: .6rem .75rem; color: var(--text-primary);
  font-family: inherit; font-size: .86rem; line-height: 1.5; outline: none; max-height: 140px;
}
.tut-input:focus { border-color: rgba(34,211,238,.5); }
.tut-send {
  flex-shrink: 0; width: 36px; height: 36px; border: none; border-radius: 9px;
  background: var(--hdl-grad); color: var(--hdl-ink); font-size: 1rem; font-weight: 700; cursor: pointer;
}
.tut-send:hover { opacity: .9; }

@media (max-width: 640px) {
  #dvp-tutor { right: 12px; bottom: 12px; }
  .tut-panel { width: calc(100vw - 24px); height: min(70vh, calc(100vh - 100px)); }
  .tut-fab-label { display: none; }
  .tut-fab { padding: .75rem; }
}
@media print { #dvp-tutor { display: none; } }

/* ---------------- TRACK SEARCH ---------------- */
#hdl-search-fab {
  position: fixed; top: 16px; right: 16px; z-index: 190;
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--bg-card); border: 1px solid var(--border-card); color: var(--text-muted);
  border-radius: 8px; padding: .35rem .6rem; font-family: inherit; font-size: .72rem; font-weight: 600;
  cursor: pointer; transition: border-color .2s, color .2s;
}
#hdl-search-fab:hover { border-color: var(--accent-cyan); color: var(--text-primary); }
#hdl-search-fab kbd { font-family: 'JetBrains Mono', monospace; font-size: .6rem; color: var(--text-muted);
  border: 1px solid var(--border-subtle); border-radius: 4px; padding: .1rem .3rem; }
@media (max-width: 640px) { #hdl-search-fab span, #hdl-search-fab kbd { display: none; } }
@media print { #hdl-search-fab { display: none; } }

#dvp-search { position: fixed; inset: 0; z-index: 300; }
.srch-backdrop { position: absolute; inset: 0; background: rgba(5,7,12,.62); backdrop-filter: blur(4px); }
.srch-panel { position: relative; max-width: 640px; margin: 9vh auto 0; background: var(--bg-secondary);
  border: 1px solid var(--border-card); border-radius: var(--hdl-radius); box-shadow: 0 30px 80px rgba(0,0,0,.6);
  display: flex; flex-direction: column; max-height: 72vh; overflow: hidden;
  animation: srch-in .22s cubic-bezier(.22,1,.36,1); }
@keyframes srch-in { from { opacity: 0; transform: translateY(-10px) scale(.985); } to { opacity: 1; transform: none; } }
.srch-inputrow { display: flex; align-items: center; gap: .7rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border-subtle); color: var(--text-muted); }
.srch-input { flex: 1; background: none; border: none; outline: none; color: var(--text-heading);
  font-family: inherit; font-size: 1rem; }
.srch-input::-webkit-search-cancel-button { display: none; }
.srch-inputrow kbd { font-family: 'JetBrains Mono', monospace; font-size: .62rem; color: var(--text-muted);
  border: 1px solid var(--border-subtle); border-radius: 4px; padding: .12rem .35rem; }
.srch-results { overflow-y: auto; flex: 1; }
.srch-item { display: block; padding: .75rem 1.1rem; border-bottom: 1px solid var(--border-subtle);
  text-decoration: none; border-left: 2px solid transparent; }
.srch-item.is-sel { background: var(--bg-highlight); border-left-color: var(--accent-cyan); }
.srch-item-top { display: flex; align-items: center; gap: .55rem; }
.srch-kind { font-size: .56rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  padding: .16rem .45rem; border-radius: 4px; flex-shrink: 0; }
.srch-kind.brief { background: rgba(129,140,248,.16); color: var(--accent-violet); }
.srch-kind.day { background: rgba(34,211,238,.14); color: var(--accent-cyan); }
.srch-title { font-weight: 700; color: var(--text-heading); font-size: .92rem; }
.srch-crumb { font-size: .7rem; color: var(--text-muted); margin: .15rem 0 .25rem; }
.srch-snip { font-size: .8rem; color: var(--text-secondary); line-height: 1.5; }
.srch-snip mark { background: rgba(34,211,238,.22); color: var(--accent-cyan); border-radius: 2px; padding: 0 1px; }
.srch-empty { padding: 1.4rem 1.2rem; color: var(--text-muted); font-size: .86rem; }
.srch-hint { padding: .55rem 1.1rem; font-size: .68rem; color: var(--text-muted); border-top: 1px solid var(--border-subtle); }
@media (max-width: 640px) { .srch-panel { margin: 4vh .8rem 0; max-height: 84vh; } }

/* ---------------- PAGE NOTES ---------------- */
#dvp-notes { position: fixed; left: 20px; bottom: 20px; z-index: 200; }
.nts-fab { display: inline-flex; align-items: center; gap: .5rem; position: relative;
  background: var(--bg-card); border: 1px solid var(--border-card); color: var(--text-secondary);
  border-radius: 100px; padding: .65rem 1rem; font-family: inherit; font-size: .8rem; font-weight: 700;
  cursor: pointer; box-shadow: 0 8px 28px rgba(0,0,0,.45);
  transition: transform .2s cubic-bezier(.22,1,.36,1), border-color .2s, color .2s, opacity .2s; }
.nts-fab:hover { transform: translateY(-2px); border-color: var(--accent-cyan); color: var(--text-primary); }
.nts-dot { position: absolute; top: 6px; right: 8px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-cyan); }
#dvp-notes.is-open .nts-fab { opacity: 0; pointer-events: none; }

.nts-panel { position: absolute; left: 0; bottom: 0; width: min(400px, calc(100vw - 40px));
  height: min(480px, calc(100vh - 120px)); display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg-secondary); border: 1px solid var(--border-card); border-radius: var(--hdl-radius);
  box-shadow: 0 24px 60px rgba(0,0,0,.6); animation: nts-in .26s cubic-bezier(.22,1,.36,1); }
.nts-panel[hidden] { display: none; }
@keyframes nts-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.nts-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem 1rem .85rem 1.1rem; border-bottom: 1px solid var(--border-subtle); }
.nts-eyebrow { font-size: .6rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-cyan); }
.nts-title { font-size: .88rem; font-weight: 700; color: var(--text-heading); }
.nts-close { background: none; border: none; color: var(--text-muted); font-size: .9rem; cursor: pointer;
  padding: .3rem .4rem; border-radius: 6px; }
.nts-close:hover { color: var(--text-heading); background: var(--bg-highlight); }
.nts-text { flex: 1; resize: none; background: var(--bg-primary); border: none; outline: none;
  padding: 1rem 1.1rem; color: var(--text-primary); font-family: inherit; font-size: .88rem; line-height: 1.65; }
.nts-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem 1rem; border-top: 1px solid var(--border-subtle); }
.nts-status { font-size: .7rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.nts-export { background: none; border: 1px solid var(--border-card); color: var(--text-secondary);
  border-radius: 8px; padding: .35rem .7rem; font-family: inherit; font-size: .72rem; font-weight: 600; cursor: pointer;
  transition: border-color .2s, color .2s; }
.nts-export:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
@media (max-width: 640px) {
  #dvp-notes { left: 12px; bottom: 12px; }
  .nts-panel { width: calc(100vw - 24px); height: min(70vh, calc(100vh - 100px)); }
  .nts-fab-label { display: none; }
  .nts-fab { padding: .75rem; }
}
@media print { #dvp-notes { display: none; } }

/* ---------------- PROGRESS CONTROLS ---------------- */
.hdl-complete-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  margin: 2rem 0 0; padding: .9rem 1rem; background: var(--bg-secondary);
  border: 1px solid var(--border-subtle); border-radius: 12px; }
.hdl-complete-btn, .hdl-stuck-btn {
  font-family: inherit; font-size: .8rem; font-weight: 700; cursor: pointer;
  border-radius: 100px; padding: .5rem .95rem; transition: border-color .2s, color .2s, background .2s; }
.hdl-complete-btn { background: none; border: 1px solid rgba(34,211,238,.45); color: var(--accent-cyan); }
.hdl-complete-btn:hover { background: rgba(34,211,238,.1); }
.hdl-complete-btn.is-on { background: var(--hdl-grad); border-color: transparent; color: var(--hdl-ink); }
.hdl-stuck-btn { background: none; border: 1px solid var(--border-card); color: var(--text-muted); }
.hdl-stuck-btn:hover { border-color: var(--accent-yellow); color: var(--accent-yellow); }
.hdl-stuck-btn.is-on { border-color: rgba(251,191,36,.55); color: var(--accent-yellow); background: rgba(251,191,36,.08); }
.hdl-complete-hint { font-size: .72rem; color: var(--text-muted); }
@media print { .hdl-complete-row { display: none; } }

/* Dashboard stuck list */
.hdl-stuck-row { grid-column: 1 / -1; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  font-size: .78rem; color: var(--text-muted, #64748b); }
.hdl-stuck-label { font-weight: 700; color: #fbbf24; }
.hdl-stuck-day { border: 1px solid rgba(251,191,36,.4); color: #fbbf24; border-radius: 100px;
  padding: .15rem .6rem; font-size: .72rem; font-weight: 600; }
