.chi-local-tools{--cl-ink:var(--ink,#f5f5f5);--cl-paper:var(--paper,#080808);--cl-surface:var(--surface,#141414);--cl-muted:var(--muted,#aaa);--cl-line:var(--line,#303030);--cl-radius:var(--r-control,10px);font-family:var(--font,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif);color:var(--cl-ink);background:var(--cl-paper);color-scheme:dark;font-size:16px;line-height:1.55;max-width:960px;margin:auto;padding:24px;overflow-wrap:anywhere}
.chi-local-tools *{box-sizing:border-box}.chi-local-tools [hidden]{display:none!important}.chi-local-tools h2{font-size:28px;font-weight:550;margin:0}.chi-local-tools h3{font-size:22px;margin:24px 0 8px}.chi-local-tools h4{font-size:18px;margin:24px 0 12px}.chi-local-tools p{max-width:72ch;color:var(--cl-muted)}.chi-local-tools button,.chi-local-tools input,.chi-local-tools select,.chi-local-tools textarea{font:inherit;color:inherit;min-height:44px;max-width:100%}.chi-local-tools input,.chi-local-tools select,.chi-local-tools textarea{border:1px solid var(--cl-line);border-radius:var(--cl-radius);background:var(--cl-surface);padding:10px;width:100%}.chi-local-tools textarea{resize:vertical}.chi-local-tools label{display:block;margin:12px 0}.chi-local-tools button{border:1px solid var(--cl-line);border-radius:var(--cl-radius);background:var(--cl-surface);padding:10px 16px;cursor:pointer;touch-action:manipulation}.chi-local-tools button:hover{border-color:var(--cl-muted)}.chi-local-tools button[aria-pressed=true]{background:var(--cl-ink);color:var(--cl-paper)}.chi-local-tools button:disabled{opacity:.5;cursor:default}.chi-local-tools :focus-visible{outline:2px solid var(--cl-ink);outline-offset:3px}.chi-local-tools .cl-nav,.chi-local-tools .cl-actions{display:flex;flex-wrap:wrap;gap:8px;margin:16px 0}.chi-local-tools .cl-nav{padding-bottom:20px;border-bottom:1px solid var(--cl-line)}.chi-local-tools fieldset{border:0;padding:0;margin:16px 0;min-width:0}.chi-local-tools legend{font-weight:600;margin:8px 0}.chi-local-tools .cl-fields{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.chi-local-tools .cl-preview{display:flex;flex-wrap:wrap;gap:16px;align-items:start}.chi-local-tools canvas,.chi-local-tools img{max-width:100%;max-height:420px;object-fit:contain;border:1px solid var(--cl-line)}.chi-local-tools .cl-preview img{max-width:45%}.chi-local-tools pre{font:14px/1.6 ui-monospace,monospace;white-space:pre-wrap;overflow-wrap:anywhere;margin:12px 0}.chi-local-tools details{border-block:1px solid var(--cl-line);margin:16px 0;padding:8px 0}.chi-local-tools summary{cursor:pointer;min-height:44px;padding:10px 0}.chi-local-tools .cl-text-preview{max-height:420px;overflow:auto;border-block:1px solid var(--cl-line)}.chi-local-tools table{border-collapse:collapse;min-width:100%;font-size:14px}.chi-local-tools td{border:1px solid var(--cl-line);padding:8px;white-space:pre-wrap;max-width:400px;overflow-wrap:anywhere}.chi-local-tools .cl-status{min-height:24px;color:var(--cl-ink)}.chi-local-tools .cl-question,.chi-local-tools .cl-answer{font-size:20px;color:var(--cl-ink);white-space:pre-wrap}.chi-local-tools .cl-option{display:flex;gap:12px;align-items:center;min-height:44px}.chi-local-tools .cl-option input{width:20px;height:20px;min-height:20px;flex:none;accent-color:var(--cl-ink)}.chi-local-tools [data-q=edit-fields] fieldset{border-bottom:1px solid var(--cl-line);padding-bottom:16px}
@media(max-width:600px){.chi-local-tools{padding:16px}.chi-local-tools .cl-fields{grid-template-columns:repeat(2,minmax(0,1fr))}.chi-local-tools .cl-preview{display:block}.chi-local-tools .cl-preview img{max-width:100%;margin-top:16px}.chi-local-tools .cl-actions button{flex:1 1 auto}.chi-local-tools .cl-nav button{flex:1}.chi-local-tools td{min-width:80px}.chi-local-tools .cl-heading p{font-size:14px}}
.chi-local-tools .cl-preview figure{margin:0;max-width:45%}.chi-local-tools .cl-preview figure img{max-width:100%;display:block}.chi-local-tools figcaption{font-size:14px;color:var(--cl-muted);margin:8px 0}@media(max-width:600px){.chi-local-tools .cl-preview figure{max-width:100%}}

.local-tools-surface{max-width:1040px;margin:0 auto;padding:32px 24px}.local-tools-surface[hidden]{display:none}.local-tools-toolbar{display:flex;justify-content:space-between;align-items:center;gap:16px;padding-bottom:20px;border-bottom:1px solid var(--line)}.local-tools-toolbar h2{font-size:20px;margin:0}.local-tools-toolbar>div{display:flex;flex-wrap:wrap;gap:12px}.local-tools-surface .chi-local-tools{padding-inline:0}@media(max-width:600px){.local-tools-surface{padding:24px 18px}.local-tools-toolbar{align-items:flex-start;flex-direction:column}.local-tools-toolbar>div{width:100%;justify-content:space-between}}
/* Existing tools: one heading, an action first, detail when needed. */
body.encounter .local-tools-surface{padding-top:18px}
body.encounter .local-tools-toolbar{padding-bottom:16px}
body.encounter .local-tools-toolbar h2{font-size:22px;letter-spacing:-.6px}
body.encounter .chi-local-tools{padding-top:12px}
body.encounter .chi-local-tools .cl-heading p{font-size:12px;margin:0 0 16px}
body.encounter .chi-local-tools h3{font-size:24px;letter-spacing:-.7px;margin-top:22px}
body.encounter .chi-local-tools .cl-nav{margin-top:0;padding-bottom:16px}
body.encounter .chi-local-tools .cl-nav button{font-size:13px;flex:1;white-space:nowrap;padding:10px}
body.encounter .chi-local-tools .cl-file{margin:18px 0;padding:16px;border:1px solid #414141;border-radius:16px;background:linear-gradient(140deg,#ffffff0b,#ffffff03);font-size:15px;font-weight:500}
body.encounter .chi-local-tools .cl-file input{margin-top:10px;background:#111;font-size:13px;font-weight:400}
body.encounter .chi-local-tools .cl-limits{margin:12px 0;border:0;padding:0;font-size:12px}
body.encounter .chi-local-tools .cl-limits summary{min-height:36px;padding:5px 0;color:#aaa}
body.encounter .chi-local-tools [data-q=image-fields][disabled]{display:none}
body.encounter .local-tools-surface:not(:has([data-q=image-preview]:not([hidden]),[data-q=text-preview]>*,[data-q=study-content]:not([hidden]),textarea:not(:placeholder-shown))) #reset-local-tools{display:none}
body.encounter .chi-local-tools .cl-fields{grid-template-columns:repeat(2,minmax(0,1fr))}
body.encounter .chi-local-tools p{font-size:14px;line-height:1.6}
body.encounter .chi-local-tools .cl-limits p{font-size:12px}
@media(max-width:600px){body.encounter .local-tools-toolbar{flex-direction:row;align-items:center}body.encounter .local-tools-toolbar>div{width:auto;gap:8px}body.encounter .local-tools-toolbar>div .text-button{font-size:12px;padding:10px 0}body.encounter .chi-local-tools h3{font-size:22px}body.encounter .chi-local-tools .cl-file{padding:14px}}
body.encounter .chi-local-tools [data-q=image-panel]:not(:has([data-q=image-preview]:not([hidden]))) .cl-actions,body.encounter .chi-local-tools [data-q=image-panel]:not(:has([data-q=image-preview]:not([hidden]))) [data-q=image-info]{display:none}
body.encounter .chi-local-tools [data-q=study-panel]:not(:has([data-q=study-content]:not([hidden]),[data-q=deck-input]:not(:placeholder-shown))) [data-q=deck-reset]{display:none}
