body.demo {
  max-width: 600px;
  margin: auto;
  padding: 20px;
  font-family: sans-serif;
}

.demo ul {
  margin-bottom: 32px;
}

.demo li {
  margin-bottom: 16px;
}

.demo pre {
  margin-bottom: 32px;
}

.edit-popover {
  width: 100%;
  max-width: min(420px, calc(100vw - 48px));
}

.edit-popover,
.icon-popover {
  position: absolute;
  background: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 10px;
  border-radius: 6px;
  z-index: 20;
  border: 1px solid #eee;
}

.edit-popover textarea.text-editor {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 100%;
  box-sizing: border-box;
  resize: none; /* Prevent manual resizing since we're auto-growing */
  overflow-y: hidden; /* Hide scrollbar as we'll auto-grow */
  line-height: 1.5; /* Better line spacing for readability */
  font-family: inherit; /* Use the same font as the page */
  min-height: 60px; /* Minimum height */
}

/* Keep handles clickable even if behind other relatively positioned content */
.edit-handle {
  position: absolute;
  font-size: 12px;
  background-color: rgba(235, 235, 235, 0.8);
  color: #555;
  padding: 2px 5px;
  border-radius: 3px;
  cursor: pointer;
  z-index: 10; /* Below popovers */
  font-family: sans-serif;
  white-space: nowrap;
  user-select: none;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  border: 1px solid #949494;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.edit-handle:hover {
  opacity: 1;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(6, auto);
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding: 5px; /* Padding inside the scrollable area */
}

.icon-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.icon-btn:hover,
.icon-btn:focus {
  background-color: #f0f0f0;
  border-color: #ccc;
  outline: none;
}

.icon-btn svg {
  width: 24px;
  height: 24px;
  stroke: currentColor; /* Or specific color */
  fill: none; /* Adjust if using filled icons */
  stroke-width: 1.5;
}

/* Style for the icon placeholder itself */
.editable-icon-placeholder {
  display: inline-flex; /* Aligns icon better */
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  vertical-align: middle; /* Align with text */
  border: 1px dashed transparent; /* Show area when empty */
}
.editable-icon-placeholder:empty {
  border-color: lightgray;
}

/* Common style for the highlight (used for page load, tab focus, scrolling) */
[editmode="true"] [data-editable].highlight-editable,
[editmode="true"][data-scrolling="true"] [data-editable] {
  outline: 2px dashed rgb(251, 156, 230);
}

/* Show outline on hover in edit mode */
[editmode="true"] [data-editable]:hover {
  outline: 2px dashed rgb(251, 156, 230);
}

/* Hide edit handle when edit mode is off */
[editmode="false"] .edit-handle {
  display: none;
}

strong { font-weight: bold; }
em { font-style: italic; }
code { background-color: #f0f0f0; padding: 2px 4px; border-radius: 3px; font-family: monospace; }
pre { background-color: #f5f5f5; padding: 10px; border-radius: 4px; overflow-x: auto; }
pre code { background-color: transparent; padding: 0; }
a { color: dodgerblue; text-decoration: underline; }
ul, ol { margin-left: 20px; padding-left: 20px; }