.snippets-toggle { margin-left: 0 !important; }
.snippets-panel { max-height: 55%; overflow: auto; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.snippets-panel[hidden] { display: none !important; }
/* Drawer: covers the output side (canvas or preview); the editor stays in view for pasting. */
.ref-host { position: relative; }
.snippets-panel.drawer { position: absolute; inset: 0; z-index: 20; max-height: none; display: flex; flex-direction: column; padding: 0; border-radius: 0; border-width: 0 0 0 1px; box-shadow: -6px 0 18px rgba(0, 0, 0, .12); overflow: hidden; }
.snippets-panel.drawer .ref-body { flex: 1; overflow: auto; padding: 0 10px 10px; }
.ref-top { padding: 8px 10px 4px; border-bottom: 1px solid var(--line); background: var(--panel); }
.ref-titlebar { display: flex; align-items: center; justify-content: space-between; }
.ref-titlebar h2 { margin: 0; font: 600 14px system-ui, sans-serif; color: var(--ink); }
.ref-close { border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; padding: 2px 6px; cursor: pointer; border-radius: 6px; }
.ref-close:hover, .ref-close:focus-visible { color: var(--ink); outline: 2px solid var(--accent); }
.ref-search { width: 100%; box-sizing: border-box; margin: 6px 0; padding: 6px 9px; font: 13px system-ui, sans-serif; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--ink); }
.ref-search:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.ref-filter { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.ref-filter button { font: 12.5px system-ui, sans-serif; padding: 3px 11px; border: 0; background: var(--bg); color: var(--muted); cursor: pointer; }
.ref-filter button + button { border-left: 1px solid var(--line); }
.ref-filter button[aria-checked="true"] { background: var(--accent); color: #fff; }
.ref-filter button[hidden] { display: none; }
.ref-empty { font-size: 13px; color: var(--muted); }
@media (max-width: 700px) { .snippets-panel.drawer { position: fixed; border-width: 0; box-shadow: none; } }
.snippets-panel details { padding: 2px 0; }
.snippets-panel summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); padding: 4px 0; }
.ref-intro { margin: 8px 0 4px; font-size: 12.5px; color: var(--muted); }
.ref-intro kbd { font: 11.5px ui-monospace, Menlo, Consolas, monospace; padding: 0 4px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); }
.ref-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; padding: 4px 0 10px; align-items: start; }
.ref-card { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 6px 8px 8px; min-width: 0; }
.ref-head { display: flex; align-items: center; gap: 4px; }
.ref-name { flex: 1; font: 600 12.5px ui-monospace, Menlo, Consolas, monospace; color: var(--ink); overflow-wrap: anywhere; }
.ref-hint, .ref-where, .ref-lock { margin: 3px 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.ref-where { font-weight: 600; margin-top: 6px; }
.ref-lock:empty { display: none; }
.ref-code { display: flex; gap: 6px; align-items: flex-start; margin-top: 4px; }
.ref-code pre { flex: 1; min-width: 0; margin: 0; padding: 5px 8px; overflow-x: auto; border-radius: 6px; background: var(--code-bg); color: var(--code-ink); font: 12.5px/1.45 ui-monospace, Menlo, Consolas, monospace; }
mark.ph { background: rgba(255, 196, 0, .28); color: inherit; border-radius: 3px; padding: 0 1px; }
.ref-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 4px; }
.snippet { font: 12px system-ui, sans-serif; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; }
.snippet:hover { border-color: var(--accent); }
.snippet:focus-visible, .snippets-panel summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.snippet.copy { flex: none; }
.snippet.small { padding: 1px 7px; color: var(--muted); }
.snippet.save { border-style: dashed; align-self: center; justify-self: start; }
.ref-card.locked { border-style: dashed; opacity: .6; }
.ref-card.locked .ref-code, .ref-card.locked .ref-where, .ref-card.locked .ref-hint { display: none; }
.ref-card.locked .ref-name::after { content: ' 🔒'; font-size: 11px; }
.snippet.save.locked { opacity: .5; cursor: not-allowed; }
.snippet.save.locked::after { content: ' 🔒'; font-size: 11px; }
.source-dialog { max-width: min(640px, 92vw); width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); padding: 14px 16px; }
.source-dialog::backdrop { background: rgba(0, 0, 0, .4); }
.source-dialog h2 { margin: 0 0 8px; font: 600 14px ui-monospace, Menlo, Consolas, monospace; }
.source-dialog pre { margin: 0 0 8px; max-height: 50vh; overflow: auto; padding: 10px 12px; border-radius: 8px; background: var(--code-bg); color: var(--code-ink); font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; }
.ref-field { display: grid; gap: 3px; margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.ref-field input, .ref-field textarea { font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--code-bg); color: var(--code-ink); }
.ref-field textarea { resize: vertical; tab-size: 4; }
.snippets-panel .note { margin: 4px 0 0; font-size: 12.5px; color: var(--accent); min-height: 1em; }
/* Example: a short program using the snippet and a picture of what it draws, opened per card. */
.ref-ex-btn { margin-left: auto; }
.ref-example { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line, #ddd); }
.ref-example figure { margin: 6px 0 0; }
.ref-example img { max-width: 100%; height: auto; border: 1px solid var(--line, #ddd); border-radius: 6px; background: #fff; display: block; }
.ref-example figcaption { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ref-card.locked .ref-ex-btn, .ref-card.locked .ref-example { display: none; }
