:root {
    --help-z: 1400;
    --help-radius: 14px;
    --help-shadow: 0 12px 40px rgba(15, 23, 42, 0.22);
}

/* ── Launcher tab (bottom-right, always present) ───────────────────────── */
.help-launcher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: var(--help-z);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px 11px 13px;
    border: 0;
    border-radius: 999px;
    background: var(--accent, #2563eb);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--help-shadow);
    transition: transform 120ms ease, filter 120ms ease, opacity 160ms ease;
}
.help-launcher:hover { filter: brightness(1.06); transform: translateY(-1px); }
.help-launcher:focus-visible { outline: 3px solid var(--accent-soft, #e0e7ff); outline-offset: 2px; }
.help-launcher-icon { width: 20px; height: 20px; flex: 0 0 auto; }

body.help-open .help-launcher { opacity: 0; pointer-events: none; }

@media (max-width: 640px) {
    .help-launcher-label { display: none; }
    .help-launcher { padding: 13px; }
}

/* ── Panel (chat-style card anchored bottom-right) ─────────────────────── */
.help-panel {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: calc(var(--help-z) + 1);
    display: flex;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 32px);
    max-height: min(640px, calc(100vh - 44px));
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: var(--help-radius);
    box-shadow: var(--help-shadow);
    overflow: hidden;
    transform: translateY(16px) scale(0.98);
    opacity: 0;
    transition: transform 160ms ease, opacity 160ms ease;
}
.help-panel[hidden] { display: none; }
.help-panel.is-open { transform: translateY(0) scale(1); opacity: 1; }

.help-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--accent, #2563eb);
    color: #fff;
}
.help-panel-title { margin: 0; font-size: 1rem; font-weight: 600; line-height: 1.3; }
.help-panel-close {
    flex: 0 0 auto;
    width: 30px; height: 30px;
    border: 0; border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 1.4rem; line-height: 1;
    cursor: pointer;
}
.help-panel-close:hover { background: rgba(255, 255, 255, 0.28); }
.help-panel-close:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.help-panel-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    color: var(--text, #111827);
    font-size: 0.9rem;
    line-height: 1.55;
}
.help-intro { color: var(--text-muted, #6b7280); }
.help-intro p:first-child { margin-top: 0; }
.help-intro p:last-child { margin-bottom: 0; }

.help-actions-title {
    margin: 18px 0 8px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted, #6b7280);
}
.help-actions { list-style: none; margin: 0; padding: 0; }
.help-action {
    padding: 12px 0;
    border-top: 1px solid var(--border, #e5e7eb);
}
.help-action:first-child { border-top: 0; }
.help-action-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}
.help-action-title { font-weight: 600; color: var(--text, #111827); }
.help-action-show {
    flex: 0 0 auto;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 7px;
    background: transparent;
    color: var(--accent, #2563eb);
    padding: 3px 9px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}
.help-action-show:hover { background: var(--accent-soft, #e0e7ff); }
.help-action-body { color: var(--text-muted, #6b7280); }
.help-action-body p:first-child { margin-top: 0; }
.help-action-body p:last-child { margin-bottom: 0; }
.help-panel-body code {
    background: var(--bg, #f6f7f9);
    padding: 1px 5px;
    border-radius: 5px;
    font-size: 0.85em;
}
.help-panel-body a { color: var(--accent, #2563eb); text-decoration: underline; }

.help-empty { color: var(--text-muted, #6b7280); margin: 0; }

.help-panel-foot {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border, #e5e7eb);
    background: var(--bg, #f6f7f9);
}
.help-btn {
    flex: 1 1 40%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 12px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 9px;
    background: var(--surface, #fff);
    color: var(--text, #111827);
    font-size: 0.83rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.help-btn:hover { border-color: var(--accent, #2563eb); }
.help-btn--primary {
    background: var(--accent, #2563eb);
    border-color: var(--accent, #2563eb);
    color: #fff;
}
.help-btn--primary:hover { filter: brightness(1.06); }

.help-target-flash {
    animation: help-target-flash 1.6s ease;
    scroll-margin: 90px;
}
@keyframes help-target-flash {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
    15%      { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.55); }
    60%      { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.30); }
}

@media (prefers-reduced-motion: reduce) {
    .help-panel, .help-launcher { transition: none; }
    .help-target-flash { animation: none; outline: 3px solid var(--accent, #2563eb); }
}
