/* ── App chrome: top bar, user menu ─────────────────────────────────────────── */
#topbar .topbar-right { gap: 8px; }
.tb-btn { cursor: pointer; background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-primary); font: inherit; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; position: relative; }
.tb-btn:hover { background: var(--bg-hover); }
.tb-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tb-round { width: 34px; height: 34px; border-radius: 50%; padding: 0; font-size: 14px; line-height: 1; }
.tb-pill { height: 34px; border-radius: 20px; padding: 0 12px; color: var(--text-secondary); }
.tb-label { color: var(--text-muted); }
.tb-user { height: 34px; border-radius: 20px; padding: 0 10px 0 4px; }
.tb-avatar { width: 24px; height: 24px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; }
.tb-client, .tb-caret { color: var(--text-muted); font-size: 11px; }
.tb-badge { position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff; font-size: 9px; font-weight: 600; min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px; align-items: center; justify-content: center; line-height: 16px; text-align: center; }
.user-menu-wrap { position: relative; }
.user-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px #00000040; padding: 6px; z-index: 600; }
.user-menu[hidden] { display: none; }
.user-menu .um-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; gap: 2px; }
.user-menu .um-head span { font-size: 11px; color: var(--text-muted); }
.user-menu button { display: flex; width: 100%; text-align: left; background: none; border: none; color: var(--text-primary); font: inherit; font-size: 12.5px; padding: 8px 10px; border-radius: 6px; cursor: pointer; align-items: center; gap: 8px; }
.user-menu button:hover, .user-menu button:focus-visible { background: var(--bg-hover); outline: none; }
.user-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
@media (max-width: 1100px) { .tb-label, .tb-client, .tb-name { display: none; } }

/* ── Per-screen help banner ─────────────────────────────────────────────────── */
.screen-help { background: var(--accent-dim); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; margin-bottom: 14px; }
.screen-help.collapsed { background: transparent; border-left-color: var(--border-light); }
.sh-toggle { width: 100%; display: flex; align-items: center; gap: 8px; background: none; border: none; color: var(--text-primary); font: inherit; font-size: 12.5px; font-weight: 600; padding: 9px 12px; cursor: pointer; text-align: left; }
.screen-help.collapsed .sh-toggle { font-weight: 500; color: var(--text-secondary); padding: 6px 12px; }
.sh-chev { margin-left: auto; color: var(--text-muted); }
.sh-body { padding: 0 14px 12px 14px; font-size: 12.5px; line-height: 1.6; color: var(--text-secondary); }
.sh-body[hidden] { display: none; }
.sh-body p { margin: 6px 0; }
.sh-body ol, .sh-body ul { margin: 4px 0 6px 20px; }
.sh-body li { margin: 3px 0; }
.sh-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; margin-top: 10px !important; }
.sh-body b { color: var(--text-primary); }
.sh-actions { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.sh-actions a { color: var(--accent); font-size: 12px; }

/* ── Help & guide page ──────────────────────────────────────────────────────── */
.hp-wrap { max-width: 920px; margin: 0 auto; padding-bottom: 60px; color: var(--text-secondary); font-size: 13.5px; line-height: 1.65; }
.hp-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.hp-h1 { font-family: var(--font-serif); font-size: 26px; font-weight: 400; color: var(--text-primary); margin: 0 0 4px; }
.hp-lead { margin: 0; color: var(--text-muted); }
.hp-top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hp-toc { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; position: sticky; top: -20px; background: var(--bg-base); padding: 8px 0; z-index: 5; }
.hp-toc a { font-size: 12px; padding: 5px 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--bg-surface); color: var(--text-secondary); text-decoration: none; }
.hp-toc a:hover { border-color: var(--accent); color: var(--accent); }
.hp-section { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 24px; margin-bottom: 16px; }
.hp-section h3 { font-family: var(--font-serif); font-weight: 400; font-size: 19px; color: var(--text-primary); margin: 0 0 10px; }
.hp-section h4 { color: var(--text-primary); font-size: 14px; margin: 18px 0 6px; }
.hp-section p { margin: 8px 0; }
.hp-section b { color: var(--text-primary); }
.hp-section code, .hp-table code { font-family: var(--font-mono); font-size: 12px; background: var(--bg-elevated); padding: 1px 6px; border-radius: 4px; color: var(--teal); }
.hp-code { font-family: var(--font-mono); font-size: 12px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; color: var(--text-primary); white-space: pre; }
.hp-small { font-size: 12px; color: var(--text-muted); }
.hp-note { background: var(--amber-dim); border-radius: 8px; padding: 10px 14px; }
.hp-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 14px 0; }
.hp-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; background: var(--bg-elevated); }
.hp-card p { margin: 6px 0 10px; font-size: 12.5px; }
.hp-card a { color: var(--accent); font-size: 12.5px; }
.hp-ico { font-size: 22px; display: block; margin-bottom: 6px; }
.hp-tree { margin: 14px 0; display: flex; flex-direction: column; gap: 6px; }
.hp-node { border: 1px solid var(--border); border-left: 4px solid var(--accent); background: var(--bg-elevated); border-radius: 8px; padding: 8px 14px; display: flex; flex-direction: column; font-size: 12.5px; }
.hp-node b { font-size: 13.5px; }
.hp-node span { color: var(--text-muted); }
.hp-node.n1 { margin-left: 28px; border-left-color: var(--teal); }
.hp-node.n2 { margin-left: 56px; border-left-color: var(--purple); }
.hp-node.n3 { margin-left: 84px; border-left-color: var(--green); }
.hp-node.n4 { margin-left: 112px; border-left-color: var(--amber); }
.hp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hp-table th { text-align: left; vertical-align: top; width: 190px; padding: 9px 12px 9px 0; color: var(--text-primary); font-weight: 600; border-bottom: 1px solid var(--border); }
.hp-table td { padding: 9px 0; border-bottom: 1px solid var(--border); }
.hp-screen { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: var(--bg-elevated); }
.hp-screen summary { cursor: pointer; padding: 10px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; list-style: none; }
.hp-screen summary::-webkit-details-marker { display: none; }
.hp-screen summary::before { content: '▸'; color: var(--text-muted); }
.hp-screen[open] summary::before { content: '▾'; }
.hp-sname { font-weight: 600; color: var(--text-primary); }
.hp-where { font-size: 11.5px; color: var(--text-muted); }
.hp-badge { margin-left: auto; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--purple); background: var(--purple-dim); padding: 2px 8px; border-radius: 10px; }
.hp-sbody { padding: 2px 16px 12px 16px; }
.hp-sbody ol, .hp-sbody ul, .hp-steps, .hp-recipe ol { margin: 4px 0 6px 20px; }
.hp-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; margin-top: 10px !important; }
.hp-sbody a { color: var(--accent); }
.hp-recipes { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.hp-recipe { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; background: var(--bg-elevated); }
.hp-recipe li { margin: 3px 0; font-size: 12.5px; }

/* ── Welcome + tour ─────────────────────────────────────────────────────────── */
.wm-overlay { position: fixed; inset: 0; background: #0009; z-index: 9000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.wm-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px 32px; max-width: 520px; width: 100%; box-shadow: 0 20px 60px #00000060; color: var(--text-secondary); line-height: 1.6; }
.wm-card h2 { font-family: var(--font-serif); font-weight: 400; font-size: 24px; color: var(--text-primary); margin: 0 0 10px; }
.wm-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.wm-three div { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; padding: 12px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.wm-three span { font-size: 22px; }
.wm-three b { color: var(--text-primary); }
.wm-three small { color: var(--text-muted); font-size: 11.5px; }
.wm-small { font-size: 12.5px; }
.wm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
#tour-spot { position: fixed; z-index: 9100; border-radius: 10px; box-shadow: 0 0 0 9999px #000a, 0 0 0 2px var(--accent); pointer-events: none; transition: all .2s; }
#tour-tip { position: fixed; z-index: 9101; width: 300px; background: var(--bg-surface); border: 1px solid var(--accent); border-radius: 12px; padding: 14px 16px; box-shadow: 0 10px 40px #00000070; color: var(--text-secondary); font-size: 12.5px; line-height: 1.55; }
#tour-tip h4 { margin: 2px 0 4px; font-size: 15px; color: var(--text-primary); }
#tour-tip p { margin: 0 0 12px; }
.tt-count { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.tt-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── role-based visibility + printing the guide ─────────────────────────────── */
body[data-role="client"] .admin-only { display: none !important; }
@media print {
  body.printing-help #sidebar, body.printing-help #topbar, body.printing-help .hp-top-actions, body.printing-help .hp-toc,
  body.printing-help .screen-help, body.printing-help .hp-sbody > p:last-child, body.printing-help .hp-card a, body.printing-help #tour-tip, body.printing-help #tour-spot { display: none !important; }
  body.printing-help { display: block !important; height: auto !important; overflow: visible !important; background: #fff !important; }
  body.printing-help #main, body.printing-help #content { display: block !important; overflow: visible !important; height: auto !important; padding: 0 !important; }
  body.printing-help .panel:not(#panel-help) { display: none !important; }
  body.printing-help .hp-section { background: #fff !important; border-color: #ccc !important; }
  body.printing-help .hp-section h3, body.printing-help .hp-section h4 { break-after: avoid; }
  body.printing-help .hp-card, body.printing-help .hp-node, body.printing-help .hp-screen, body.printing-help .hp-recipe, body.printing-help .hp-table tr, body.printing-help .hp-code { break-inside: avoid; }
  body.printing-help *, body.printing-help { color: #111 !important; }
  body.printing-help details > *:not(summary) { display: block !important; }
}
