#lightbox-overlay {
  position: fixed; top: var(--top-h); left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.72);
  z-index: 3000; display: none; align-items: center; justify-content: center;
}
#lightbox-overlay.open { display: flex; }
#lightbox-box {
  background: #fff; border-radius: 10px;
  height: 90%;
  aspect-ratio: 31 / 26;
  min-height: 340px; max-height: 900px;
  max-width: 92vw;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
#lightbox-header {
  padding: 14px 18px; border-bottom: 1px solid #e0e0e0;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
#lightbox-title { font-weight: 600; font-size: 14px; color: #333; }
#lightbox-close {
  background: none; border: none; font-size: 24px; line-height: 1;
  cursor: pointer; color: #999; padding: 0 4px;
}
#lightbox-close:hover { color: #333; }
#lightbox-body {
  flex: 1; display: flex; flex-direction: row; align-items: flex-start;
  overflow-y: auto; overflow-x: hidden;
}
#lightbox-linenos-col {
  flex-shrink: 0; width: 44px;
  padding-top: 16px;
  display: flex; flex-direction: column; align-items: flex-end;
  background: #f0f0ec; border-right: 1px solid #e0e0e0;
  user-select: none;
}
.lb-lineno {
  height: 27px;
  font-size: 11px; color: #bbb;
  font-family: 'Consolas', monospace;
  padding-right: 6px;
  display: flex; align-items: flex-start; justify-content: flex-end;
  white-space: nowrap; flex-shrink: 0;
}
#lightbox-body .node-content {
  font-size: 16px; line-height: 1.7;
  pointer-events: auto; cursor: text; user-select: text;
  flex: 1; min-width: 0; align-self: flex-start;
  overflow-y: visible;
}
#lightbox-body .node-drawing-canvas { cursor: crosshair; }
#lightbox-body .node-drawing-canvas.eraser-tool {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='28'%3E%3Crect x='2' y='2' width='12' height='24' rx='2' fill='rgba(255,255,255,0.28)' stroke='%23ffffff' stroke-width='3'/%3E%3Crect x='2' y='2' width='12' height='24' rx='2' fill='none' stroke='%231a1a1a' stroke-width='1.4'/%3E%3C/svg%3E") 8 14, crosshair;
}
#lightbox-body .node-image-block { z-index: auto; }
#lightbox-body.lb-img-only .node-content { --node-content-pad: 0px; padding: 0; }
#lightbox-body.lb-img-only .node-image-block { margin-top: 0; margin-bottom: 0; }

#help-overlay {
  position: fixed; top: var(--top-h); left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.72);
  z-index: 3000; display: none; align-items: center; justify-content: center;
}
#help-overlay.open { display: flex; }
#help-box {
  background: #fff; border-radius: 10px;
  width: 640px; max-width: 92vw;
  height: 80%; max-height: 780px; min-height: 340px;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
#help-header {
  padding: 14px 18px; border-bottom: 1px solid #e0e0e0;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
#help-title { font-weight: 600; font-size: 14px; color: #333; flex-shrink: 0; }
#help-header-actions { flex: 1; display: flex; align-items: center; gap: 8px; }
#help-audience-label { font-size: 12px; color: #777; flex-shrink: 0; }
#help-audience {
  padding: 4px 8px; font-size: 12px; border: 1px solid #ddd; border-radius: 4px;
  background: #fff; color: #444; cursor: pointer;
}
#help-copy-btn {
  padding: 4px 10px; font-size: 12px; font-weight: 500; border-radius: 4px;
  border: 1px solid #ddd; background: #fff; color: #667; cursor: pointer;
}
#help-copy-btn:hover { background: #f0f0ec; border-color: #ccc; }
#help-close {
  background: none; border: none; font-size: 24px; line-height: 1;
  cursor: pointer; color: #999; padding: 0 4px; flex-shrink: 0;
}
#help-close:hover { color: #333; }
#help-body { flex: 1; overflow-y: auto; }
#help-content {
  margin: 0; padding: 16px 20px;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  font-size: 13.5px; color: #333; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
  user-select: text; cursor: text;
}

#debug-log-overlay {
  position: fixed; top: var(--top-h); left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.72);
  z-index: 3000; display: none; align-items: center; justify-content: center;
}
#debug-log-overlay.open { display: flex; }
#debug-log-box {
  background: #fff; border-radius: 10px;
  width: 720px; max-width: 92vw;
  height: 80%; max-height: 780px; min-height: 340px;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
#debug-log-header {
  padding: 14px 18px; border-bottom: 1px solid #e0e0e0;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
#debug-log-title { font-weight: 600; font-size: 14px; color: #333; flex-shrink: 0; }
#debug-log-header-actions { flex: 1; display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
#debug-log-count { font-size: 12px; color: #777; }
#debug-log-copy-btn,
#debug-log-save-btn {
  padding: 4px 10px; font-size: 12px; font-weight: 500; border-radius: 4px;
  border: 1px solid #ddd; background: #fff; color: #667; cursor: pointer;
}
#debug-log-copy-btn:hover,
#debug-log-save-btn:hover { background: #f0f0ec; border-color: #ccc; }
#debug-log-close {
  background: none; border: none; font-size: 24px; line-height: 1;
  cursor: pointer; color: #999; padding: 0 4px; flex-shrink: 0;
}
#debug-log-close:hover { color: #333; }
#debug-log-body { flex: 1; overflow-y: auto; }
#debug-log-content {
  margin: 0; padding: 16px 20px;
  font-family: Consolas, 'SF Mono', monospace;
  font-size: 12.5px; color: #333; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
  user-select: text; cursor: text;
}

#thumb-preview-overlay {
  position: fixed; top: var(--top-h); left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.72);
  z-index: 3000; display: none; align-items: center; justify-content: center;
}
#thumb-preview-overlay.open { display: flex; }
#thumb-preview-box {
  background: #fff; border-radius: 10px;
  width: 640px; max-width: 92vw;
  max-height: 80%; display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
#thumb-preview-header {
  padding: 14px 18px; border-bottom: 1px solid #e0e0e0;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
#thumb-preview-title { font-weight: 600; font-size: 14px; color: #333; }
#thumb-preview-close {
  background: none; border: none; font-size: 24px; line-height: 1;
  cursor: pointer; color: #999; padding: 0 4px;
}
#thumb-preview-close:hover { color: #333; }
#thumb-preview-body {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-wrap: wrap; gap: 18px; justify-content: center;
}
.thumb-preview-empty {
  padding: 24px 16px; color: #999; font-size: 13px; text-align: center;
}
.thumb-preview-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.thumb-preview-img-wrap {
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.thumb-preview-img-wrap img { display: block; width: 100%; height: 100%; }
.thumb-preview-caption { width: 100%; font-size: 11px; color: #777; text-align: center; line-height: 1.4; }

#save-options-overlay {
  position: fixed; top: var(--top-h); left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.72);
  z-index: 3000; display: none; align-items: center; justify-content: center;
}
#save-options-overlay.open { display: flex; }
#save-options-box {
  background: #fff; border-radius: 10px;
  width: 360px; max-width: 92vw;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
#save-options-header {
  padding: 14px 18px; border-bottom: 1px solid #e0e0e0;
  display: flex; align-items: center; justify-content: space-between;
}
#save-options-title { font-weight: 600; font-size: 14px; color: #333; }
#save-options-close {
  background: none; border: none; font-size: 24px; line-height: 1;
  cursor: pointer; color: #999; padding: 0 4px;
}
#save-options-close:hover { color: #333; }
#save-options-body { padding: 16px 18px; }

.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.opt-row-text { flex: 1; min-width: 0; }
.opt-row-title { font-size: 13.5px; color: #333; font-weight: 500; }
.opt-row-desc { margin-top: 4px; font-size: 12px; color: #888; line-height: 1.5; }

.switch { position: relative; display: inline-block; flex-shrink: 0; width: 36px; height: 20px; }
.switch input {
  position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer;
}
.switch-slider {
  position: absolute; inset: 0; border-radius: 20px; background: #ccc;
  transition: background 0.15s; pointer-events: none;
}
.switch-slider::before {
  content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: transform 0.15s;
}
.switch input:checked + .switch-slider { background: #4a9eff; }
.switch input:checked + .switch-slider::before { transform: translateX(16px); }
.switch input:focus-visible + .switch-slider { outline: 2px solid #4a9eff; outline-offset: 2px; }
