body { margin: 0; background: #1a1b1f; overflow: hidden;
		 font-family: ui-sans-serif, system-ui, "Segoe UI", sans-serif; }
/* the sketch owns all touch gestures (two-finger pan/zoom, drag), so stop the
	browser from treating them as page scroll or pinch-zoom */
canvas { touch-action: none; }

#dialog-root { display: none; }
#dialog-root.open { display: block; }

.dlg-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.dlg {
  width: 320px; padding: 18px; border-radius: 8px;
  background: #24262b; border: 1px solid #454a56;
  box-shadow: 0 18px 50px rgba(0,0,0,.55);
}
.dlg-title { color: #eceef2; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.dlg-label { color: #8d93a1; font-size: 11px; margin-bottom: 10px; }
.dlg-input {
  width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 4px;
  background: #16171b; border: 1px solid #4a505e; color: #eceef2;
  font-size: 13px; outline: none; font-family: inherit;
}
.dlg-input:focus { border-color: #7fb6e8; }
.dlg-textarea { min-height: 84px; resize: vertical; line-height: 1.4; }
.dlg-field { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.dlg-field-label { color: #8d93a1; font-size: 12px; flex: 1; }
.dlg-extra {
  padding: 5px 8px; border-radius: 4px; background: #16171b;
  border: 1px solid #4a505e; color: #eceef2; font-size: 13px; font-family: inherit;
}
.dlg-extra[type="number"] { width: 84px; }
.dlg-extra[type="color"] { width: 44px; height: 30px; padding: 2px; cursor: pointer; }
.dlg-hint { color: #6b7180; font-size: 10px; margin-top: 6px; }
.dlg-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.dlg-btn {
  padding: 7px 14px; border-radius: 4px; border: 1px solid #4a505e;
  background: #2f333c; color: #dfe2e8; font-size: 12px; cursor: pointer;
  font-family: inherit;
}
.dlg-btn:hover { background: #3b414c; }
.dlg-ok { background: #3c6d99; border-color: #4f88b8; color: #fff; }
.dlg-ok:hover { background: #4a80b0; }
/* --- Circuits library modal --- */
.circuits-panel {
  display: flex; flex-direction: column; width: min(720px, 94vw); max-height: 86vh;
  background: #1e2024; border: 1px solid #454a56; border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6); overflow: hidden;
}
.circuits-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid #33373f; background: #24262b;
}
.circuits-title { color: #eceef2; font-size: 15px; font-weight: 600; }
.circuits-head-actions { display: flex; gap: 8px; }
.circuits-body { padding: 8px 16px 16px; overflow-y: auto; }
.circuits-section { margin-top: 14px; }
.circuits-section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.circuits-section-name { color: #cdd2db; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.circuits-section-count { color: #6b7180; font-size: 11px; }
.circuits-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.circuits-card {
  display: flex; flex-direction: column; gap: 4px; padding: 8px;
  background: #262930; border: 1px solid #3a3f49; border-radius: 6px;
}
.circuits-card-name { color: #e6e9ef; font-size: 12px; font-weight: 600; cursor: pointer; word-break: break-word; }
.circuits-card-name:hover { color: #7fb6e8; }
.circuits-card-tag { color: #7d8493; font-size: 10px; }
.circuits-card-foot { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.circuits-move {
  flex: 1; min-width: 0; background: #16171b; border: 1px solid #3a3f49; color: #cdd2db;
  border-radius: 4px; font-size: 10px; padding: 3px; font-family: inherit;
}
.circuits-mini {
  background: #2f333c; border: 1px solid #454a56; color: #cdd2db;
  border-radius: 4px; font-size: 10px; padding: 3px 7px; cursor: pointer; font-family: inherit;
}
.circuits-mini:hover { background: #3b414c; }
.circuits-mini.danger { color: #e79a9a; }
.circuits-mini.danger:hover { background: #5a2f2f; }
.circuits-empty { color: #5b6069; font-size: 11px; font-style: italic; padding: 4px 2px; }
.circuits-msg { color: #e0a06a; font-size: 11px; margin-top: 8px; }
.circuits-prompt { display: flex; gap: 6px; margin-top: 10px; }
.circuits-prompt .dlg-input { flex: 1; }
/* --- Read-Out config modal --- */
.ro-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.ro-funcs { gap: 5px; }
.ro-label { color: #8d93a1; font-size: 11px; width: 40px; }
.ro-preview { color: #96ecc8; font-size: 12px; margin-left: auto; font-variant-numeric: tabular-nums; }
.dlg-btn[disabled] { opacity: .4; cursor: default; }
/* --- manual overlay --- */
#manual-root { display: none; }
#manual-root.open { display: block; }
.manual-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.manual-panel {
  display: flex; flex-direction: column;
  width: min(780px, 92vw); max-height: 88vh;
  background: #1e2024; border: 1px solid #454a56; border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6); overflow: hidden;
}
.manual-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid #33373f;
  background: #24262b; flex: 0 0 auto;
}
.manual-title { color: #eceef2; font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.manual-tools { display: flex; align-items: center; gap: 6px; }
.manual-search {
  appearance: none; width: 200px; max-width: 42vw; padding: 5px 9px; border-radius: 6px;
  background: #16171b; border: 1px solid #454a56; color: #eceef2; font-size: 13px;
  font-family: inherit; outline: none;
}
.manual-search:focus { border-color: #7fb6e8; }
.manual-count { color: #8d93a1; font-size: 12px; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.manual-nav {
  appearance: none; border: 1px solid #454a56; background: #2f333c; color: #cfd3db;
  width: 26px; height: 28px; border-radius: 6px; font-size: 11px; line-height: 1; cursor: pointer;
}
.manual-nav:hover { background: #3b414c; color: #fff; }
.manual-close {
  appearance: none; border: 1px solid #454a56; background: #2f333c;
  color: #cfd3db; width: 28px; height: 28px; border-radius: 6px;
  font-size: 18px; line-height: 1; cursor: pointer;
}
.manual-close:hover { background: #3b414c; color: #fff; }
.manual-body mark.manual-hit { background: #4a4527; color: #ffe9a6; border-radius: 2px; }
.manual-body mark.manual-hit.current { background: #f0c040; color: #1a1400; }
.manual-body {
  overflow-y: auto; padding: 8px 26px 30px;
  color: #c8ccd4; font-size: 14px; line-height: 1.6;
}
.manual-body h1 { color: #f0f2f6; font-size: 22px; margin: 22px 0 10px; }
.manual-body h2 {
  color: #eaecf1; font-size: 18px; margin: 30px 0 10px;
  padding-top: 14px; border-top: 1px solid #2c3038;
}
.manual-body h3 { color: #b7d6f2; font-size: 15px; margin: 20px 0 8px; }
.manual-body p { margin: 10px 0; }
.manual-body ul { margin: 10px 0; padding-left: 22px; }
.manual-body li { margin: 5px 0; }
.manual-body a { color: #7fb6e8; }
.manual-body strong { color: #eceef2; font-weight: 600; }
.manual-body code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  background: #14161a; border: 1px solid #2c3038; border-radius: 4px;
  padding: 1px 5px; font-size: 12.5px; color: #e0c98a;
}
.manual-body pre {
  background: #14161a; border: 1px solid #2c3038; border-radius: 6px;
  padding: 12px 14px; overflow-x: auto; margin: 12px 0;
}
.manual-body pre code {
  background: none; border: none; padding: 0; color: #a9c7a2;
  font-size: 12.5px; line-height: 1.5; white-space: pre;
}
.manual-body blockquote {
  margin: 12px 0; padding: 6px 14px; border-left: 3px solid #4f88b8;
  background: #202632; color: #aeb4bf;
}
.manual-body hr { border: none; border-top: 1px solid #2c3038; margin: 22px 0; }
.manual-body table {
  border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 13px;
}
.manual-body th, .manual-body td {
  border: 1px solid #333842; padding: 7px 10px; text-align: left; vertical-align: top;
}
.manual-body th { background: #262a31; color: #dfe3ea; font-weight: 600; }
.manual-body tr:nth-child(even) td { background: #202329; }
.manual-body::-webkit-scrollbar { width: 11px; }
.manual-body::-webkit-scrollbar-thumb {
  background: #3a3f49; border-radius: 6px; border: 2px solid #1e2024;
}
.manual-body::-webkit-scrollbar-thumb:hover { background: #4a505c; }
