/* User manual page (help.js) and the assistant window (assistant.js). Uses the Clean tokens from index.html. */

/* ---------- manual ---------- */
.help-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
.help-toc { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; scrollbar-width: thin; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px; }
.help-toc input { width: 100%; margin-bottom: 8px; }
.help-toc-group { font-family: var(--mono); font-size: calc(11px * var(--fs, 1)); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-mute); margin: 12px 8px 4px; }
.help-toc-link { display: block; padding: 5px 8px; border-radius: var(--radius); color: var(--ink-soft); text-decoration: none; font-size: calc(13px * var(--fs, 1)); line-height: 1.35; }
.help-toc-link:hover { background: var(--accent-soft); color: var(--accent); }
.help-group-title { font-family: var(--serif); font-size: calc(18px * var(--fs, 1)); font-weight: 600; margin: 8px 0 12px; }
.help-group + .help-group .help-group-title { margin-top: 28px; }
.help-sec { padding: 20px 24px; margin-bottom: 14px; scroll-margin-top: 16px; }
.help-sec h3 { font-family: var(--serif); font-size: calc(16px * var(--fs, 1)); font-weight: 600; margin: 0 0 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.help-who { font-family: var(--sans); font-size: calc(11px * var(--fs, 1)); font-weight: 500; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 10px; }
.help-body { font-size: calc(14px * var(--fs, 1)); line-height: 1.6; color: var(--ink); max-width: 75ch; }
.help-body p { margin: 0 0 10px; }
.help-body ol, .help-body ul { margin: 0 0 10px; padding-left: 22px; }
.help-body li { margin-bottom: 4px; }
.help-body code { font-family: var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: var(--radius); }
.help-body a { color: var(--accent); }
.help-note { color: var(--ink-soft); background: var(--surface-2); border-left: 3px solid var(--primary); padding: 8px 12px; border-radius: var(--radius); }
.help-table { border-collapse: collapse; width: 100%; margin: 4px 0 10px; font-size: calc(13px * var(--fs, 1)); }
.help-table th, .help-table td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.help-table th { background: var(--surface-2); font-weight: 600; }
.help-go { margin-top: 4px; }
.help-flash { animation: helpFlash 1.6s ease-out; }
@keyframes helpFlash { 0%, 30% { box-shadow: 0 0 0 3px rgba(59,130,246,0.45); } 100% { box-shadow: none; } }
@media (max-width: 900px) {
  .help-layout { grid-template-columns: minmax(0, 1fr); }
  .help-toc { position: static; max-height: 240px; }
  .help-sec { padding: 16px; }
  .help-table { display: block; overflow-x: auto; }
}

/* Print / Save as PDF: only the manual, every section open */
@media print {
  body.printing-manual .sidebar, body.printing-manual .asst-fab, body.printing-manual .asst-panel,
  body.printing-manual .help-toc, body.printing-manual .page-head-actions, body.printing-manual .help-go,
  body.printing-manual .toast, body.printing-manual .install-banner { display: none !important; }
  body.printing-manual .app { display: block !important; }
  body.printing-manual .view:not(#view-help) { display: none !important; }
  body.printing-manual .help-layout { display: block; }
  body.printing-manual .help-sec { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
  body.printing-manual .help-group, body.printing-manual .help-sec { display: block !important; }
}

/* ---------- assistant ---------- */
.asst-fab { position: fixed; right: 20px; bottom: 20px; z-index: 45; display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; min-height: 44px;
  border: none; border-radius: 999px; background: var(--accent); color: #fff; font: 500 calc(14px * var(--fs, 1)) var(--sans); cursor: pointer; box-shadow: 0 6px 18px rgba(37,99,235,0.35); }
.asst-fab:hover { background: var(--accent-hover); }
.asst-fab:focus-visible { outline: none; box-shadow: var(--focus), 0 6px 18px rgba(37,99,235,0.35); }
body.asst-is-open .asst-fab { display: none; }
.asst-panel { position: fixed; right: 20px; bottom: 20px; z-index: 48; width: 380px; height: min(600px, calc(100vh - 40px)); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 20px 48px rgba(17,24,39,0.22); overflow: hidden; }
.asst-panel[hidden] { display: none; }
.asst-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.asst-head-btns { display: flex; gap: 2px; align-items: center; }
.asst-clear { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); border-radius: 999px; padding: 4px 10px; font: calc(12px * var(--fs, 1)) var(--sans); cursor: pointer; margin-right: 4px; white-space: nowrap; }
.asst-clear:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.asst-title { font-family: var(--serif); font-weight: 600; font-size: calc(15px * var(--fs, 1)); }
.asst-sub { font-size: calc(11.5px * var(--fs, 1)); color: var(--ink-mute); margin-top: 2px; }
.asst-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); scrollbar-width: thin; }
.asst-msg { max-width: 92%; font-size: calc(13.5px * var(--fs, 1)); line-height: 1.5; padding: 9px 12px; border-radius: 12px; overflow-wrap: anywhere; }
.asst-me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.asst-bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.asst-typing { letter-spacing: 3px; color: var(--ink-mute); animation: asstDots 1s infinite; }
@keyframes asstDots { 50% { opacity: 0.3; } }
.asst-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--surface); }
.asst-form input { flex: 1; min-width: 0; }
.asst-chips, .asst-related { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.asst-related { font-size: calc(12px * var(--fs, 1)); color: var(--ink-mute); }
.asst-chip { border: 1px solid var(--line-strong); background: var(--surface); color: var(--accent); border-radius: 999px; padding: 4px 10px; font: calc(12.5px * var(--fs, 1)) var(--sans); cursor: pointer; text-align: left; }
.asst-chip:hover { background: var(--accent-soft); border-color: var(--primary); }
.asst-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.asst-who { display: inline-block; font-size: calc(11px * var(--fs, 1)); color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; margin-bottom: 6px; }
.asst-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.asst-task { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-lg); padding: 7px 9px; cursor: pointer; font: inherit; color: inherit; }
.asst-task:hover { border-color: var(--primary); background: var(--accent-soft); }
.asst-task-top { display: block; font-size: calc(13px * var(--fs, 1)); }
.asst-task-meta { display: block; font-size: calc(11.5px * var(--fs, 1)); color: var(--ink-mute); margin-top: 3px; }
.asst-turn { color: var(--accent); }
.asst-card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 8px 10px; background: var(--surface); }
.asst-ext { font-family: var(--mono); font-size: calc(12px * var(--fs, 1)); color: var(--accent); margin-left: 4px; }
.asst-links { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; font-size: calc(12.5px * var(--fs, 1)); }
.asst-links a { color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }
.asst-ul { margin: 8px 0 0; padding-left: 18px; }
.asst-ul li { margin-bottom: 6px; }
.asst-sub-line { font-size: calc(11.5px * var(--fs, 1)); color: var(--ink-mute); }
.asst-load li .tk-load-lv, .asst-msg > .tk-load-lv { font-size: calc(10.5px * var(--fs, 1)); padding: 1px 7px; margin-left: 4px; white-space: nowrap; }
.asst-away { font-size: calc(11px * var(--fs, 1)); color: var(--ink-mute); white-space: nowrap; margin-left: 4px; }
.asst-due { color: var(--warning); }
.asst-late { color: var(--danger); }
.asst-facts { margin-top: 8px; font-size: calc(12.5px * var(--fs, 1)); display: flex; flex-direction: column; gap: 3px; }
@media (max-width: 700px) {
  .asst-fab { right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); }
  .asst-panel { inset: 0; width: auto; height: auto; border-radius: 0; border: none; z-index: 210; /* full screen, above the install banner */ }
  .asst-form { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .asst-typing, .help-flash { animation: none; } }
