.md-wysiwyg-editor-wrapper {
 border: 1px solid var(--md-default-fg-color--lightest, #ddd);
 border-radius: 8px;
 background-color: var(--md-default-bg-color, #fff);
 overflow: hidden;
 display: flex;
 flex-direction: column;
 position: relative;
}

.md-toolbar {
 background-color: var(--md-default-bg-color--light, #f7f7f7);
 padding: 8px 7px;
 border-bottom: 1px solid var(--md-default-fg-color--lightest, #ddd);
 display: flex;
 flex-wrap: wrap;
 gap: 5px;
 align-items: center;
}

.md-toolbar-button {
 padding: 6px 8px;
 border: 1px solid var(--md-default-fg-color--lighter, #ccc);
 background-color: var(--md-default-bg-color, #fff);
 border-radius: 4px;
 cursor: pointer;
 font-size: 14px;
 transition: background-color 0.2s ease;
 display: inline-flex;
 align-items: center;
 justify-content: center;
 min-width: 30px;
 min-height: 30px;
}

.md-toolbar-button:hover {
 background-color: var(--md-default-bg-color--lighter, #e9e9e9);
 border-color: var(--md-default-fg-color--lighter, #bbb);
}

.md-toolbar-button.active {
 background-color: var(--md-accent-fg-color--transparent, #d0e4ff);
 border-color: var(--md-accent-fg-color, #007bff);
 color: var(--md-accent-fg-color, #0056b3);
}

.md-toolbar-button svg {
 width: 18px;
 height: 18px;
 vertical-align: middle;
}

.md-toolbar-button-heading {
 font-weight: 700;
 font-size: 13px;
 letter-spacing: -0.5px;
 width: 36px;
 box-sizing: border-box;
}

.md-toolbar-heading-wrapper {
 position: relative;
 display: inline-flex;
}

.md-heading-dropdown {
 position: absolute;
 top: 100%;
 left: 0;
 z-index: 100;
 background: var(--md-default-bg-color, #fff);
 border: 1px solid var(--md-default-fg-color--lighter, #ccc);
 border-radius: 4px;
 box-shadow: var(--md-shadow-z2, 0 4px 12px rgba(0,0,0,0.15));
 min-width: 120px;
 padding: 4px 0;
 margin-top: 2px;
}

.md-heading-dropdown-item {
 display: flex;
 align-items: center;
 width: 100%;
 padding: 6px 12px;
 border: none;
 background: none;
 cursor: pointer;
 font-size: 14px;
 text-align: left;
 color: var(--md-default-fg-color, #333);
 transition: background-color 0.15s ease;
}

.md-heading-dropdown-item:hover {
 background-color: var(--md-default-bg-color--lighter, #e9e9e9);
}

.md-heading-dropdown-item.active {
 background-color: var(--md-accent-fg-color--transparent, #d0e4ff);
 color: var(--md-accent-fg-color, #0056b3);
 font-weight: 600;
}

.md-heading-dropdown-item-h1 .md-heading-dropdown-label { font-size: 20px; font-weight: 700; }
.md-heading-dropdown-item-h2 .md-heading-dropdown-label { font-size: 18px; font-weight: 700; }
.md-heading-dropdown-item-h3 .md-heading-dropdown-label { font-size: 16px; font-weight: 600; }
.md-heading-dropdown-item-h4 .md-heading-dropdown-label { font-size: 15px; font-weight: 600; }
.md-heading-dropdown-item-h5 .md-heading-dropdown-label { font-size: 14px; font-weight: 500; }
.md-heading-dropdown-item-h6 .md-heading-dropdown-label { font-size: 13px; font-weight: 500; }

.md-editor-content-area {
 position: relative;
 display: flex;
 flex-direction: column;
 height: 500px;
}

/* Editor structural styles — always apply */
.md-editable-area {
 height: 100%;
 overflow-y: auto;
 padding: 3px;
 outline: none;
 word-wrap: break-word;
 width: 100%;
 box-sizing: border-box;
 border: none;
 background-color: var(--md-default-bg-color, #fff);
 color: var(--md-typeset-color, inherit);
 font-family: var(--md-text-font-family, inherit);
}

/* Editor-specific: pre needs its own background because pre code is reset to transparent */
.md-editable-area pre {
 background-color: var(--md-code-bg-color, #f0f0f0);
 font-size: .85em;
 padding: .75em .6rem;
}

/* Editor-specific: pre code must reset bg for our code-block structure */
.md-editable-area pre code {
 background-color: transparent;
 padding: 0;
 font-size: inherit;
 color: inherit;
}

/* Editor-specific: override blockquote italic for non-text children */
.md-editable-area blockquote pre,
.md-editable-area blockquote .md-code-block,
.md-editable-area blockquote .admonition {
 font-style: normal;
 color: inherit;
}

/* Editor-specific: tables need display:table and full width for editing
   (Material uses display:inline-block and font-size:.64rem which breaks editing) */
.md-editable-area table {
 border-collapse: collapse;
 width: 100%;
 margin-bottom: 1em;
 border: 1px solid var(--md-typeset-table-color, #ddd);
}

.md-editable-area th,
.md-editable-area td {
 border: 1px solid var(--md-typeset-table-color, #ddd);
 padding: 8px 10px;
 text-align: left;
 min-width: 50px;
}

.md-editable-area th {
 background-color: var(--md-default-bg-color--light, #f7f7f7);
 font-weight: bold;
}

.md-editable-area td:empty::before,
.md-editable-area th:empty::before {
 content: "\200B";
}

/* Typography fallback — only applies when Material .md-typeset is NOT present */
.md-editable-area:not(.md-typeset) {
 font-size: 15px;
 line-height: 1.7;
}

.md-editable-area:not(.md-typeset) h1 {
 font-size: 2em;
 font-weight: bold;
 margin-top: 0.67em;
 margin-bottom: 0.67em;
 border-bottom: 1px solid var(--md-default-fg-color--lightest, #eee);
 padding-bottom: 0.3em;
 color: var(--md-default-fg-color--light, inherit);
}

.md-editable-area:not(.md-typeset) h2 {
 font-size: 1.5em;
 font-weight: bold;
 margin-top: 0.83em;
 margin-bottom: 0.83em;
 border-bottom: 1px solid var(--md-default-fg-color--lightest, #eee);
 padding-bottom: 0.3em;
}

.md-editable-area:not(.md-typeset) h3 {
 font-size: 1.17em;
 font-weight: bold;
 margin-top: 1em;
 margin-bottom: 1em;
}

.md-editable-area:not(.md-typeset) p {
 margin-bottom: 1em;
}

.md-editable-area:not(.md-typeset) strong,
.md-editable-area:not(.md-typeset) b {
 font-weight: bold;
}

.md-editable-area:not(.md-typeset) em,
.md-editable-area:not(.md-typeset) i {
 font-style: italic;
}

.md-editable-area:not(.md-typeset) s,
.md-editable-area:not(.md-typeset) del {
 text-decoration: line-through;
}

.md-editable-area:not(.md-typeset) a {
 color: var(--md-typeset-a-color, #0366d6);
 text-decoration: underline;
}

.md-editable-area:not(.md-typeset) ul,
.md-editable-area:not(.md-typeset) ol {
 margin-left: 20px;
 margin-bottom: 1em;
}

.md-editable-area:not(.md-typeset) li {
 margin-bottom: 0.2em;
}

.md-editable-area:not(.md-typeset) blockquote {
 border-left: 3px solid var(--md-default-fg-color--lighter, #007bff);
 margin-left: 0;
 padding-left: 1em;
 color: var(--md-default-fg-color--light, #555);
 font-style: italic;
 margin-bottom: 1em;
}

.md-editable-area:not(.md-typeset) blockquote p {
 margin-bottom: 0.5em;
}

.md-editable-area:not(.md-typeset) pre {
 background-color: var(--md-code-bg-color, #f0f0f0);
 padding: 10px;
 border-radius: 4px;
 overflow-x: auto;
 font-family: var(--md-code-font-family, 'Menlo', 'Consolas', monospace);
 font-size: 0.9em;
 margin-bottom: 1em;
 white-space: pre;
}

.md-editable-area:not(.md-typeset) code {
 font-family: var(--md-code-font-family, 'Menlo', 'Consolas', monospace);
 background-color: var(--md-code-bg-color, #f0f0f0);
 padding: 0.1em 0.3em;
 border-radius: 3px;
 color: var(--md-code-fg-color, inherit);
}

.md-editable-area:not(.md-typeset) hr {
 margin-top: 1em;
 margin-bottom: 1em;
 border: 0;
 border-top: 1px solid var(--md-default-fg-color--lightest, #eee);
}

.md-markdown-editor-container {
 display: flex;
 height: 100%;
 background-color: var(--md-default-bg-color, #fff);
 color: var(--md-default-fg-color, #333);
 font-family: var(--md-code-font-family, 'Menlo', 'Consolas', monospace);
 font-size: 14px;
 line-height: 1.5;
 display: none;
 width: 100%;
 box-sizing: border-box;
 overflow-y: auto;
}

.md-markdown-line-numbers {
 padding: 15px 10px 15px 15px;
 text-align: right;
 user-select: none;
 background-color: var(--md-default-bg-color--light, #f7f7f7);
 color: var(--md-default-fg-color--lighter, #888);
 border-right: 1px solid var(--md-default-fg-color--lightest, #ddd);
 font-size: inherit;
 line-height: inherit;
 box-sizing: border-box;
}

.md-markdown-textarea-wrapper {
 flex-grow: 1;
 position: relative;
}

.md-markdown-area {
 min-height: 100%;
 width: 100%;
 padding: 15px;
 border: none;
 outline: none;
 resize: none;
 background-color: transparent;
 color: inherit;
 font-family: inherit;
 font-size: inherit;
 line-height: inherit;
 box-sizing: border-box;
 overflow: hidden;
}


.md-tabs {
 display: flex;
 border-top: 1px solid var(--md-default-fg-color--lightest, #ddd);
 background-color: var(--md-default-bg-color--light, #f7f7f7);
}

.md-tab-button {
 padding: 10px 15px;
 border: none;
 background-color: transparent;
 cursor: pointer;
 font-size: 14px;
 color: var(--md-default-fg-color--light, #555);
 border-right: 1px solid var(--md-default-fg-color--lightest, #ddd);
}

.md-tab-button:last-child {
 border-right: none;
}

.md-tab-button.active {
 background-color: var(--md-default-bg-color, #fff);
 color: var(--md-accent-fg-color, #007bff);
 font-weight: bold;
 border-bottom: 2px solid var(--md-accent-fg-color, #007bff);
 margin-bottom: -1px;
}

.md-tab-button:hover:not(.active) {
 background-color: var(--md-default-bg-color--lighter, #e9e9e9);
}

.md-table-grid-selector {
 position: absolute;
 background-color: var(--md-default-bg-color, #fff);
 border: 1px solid var(--md-default-fg-color--lighter, #ccc);
 box-shadow: var(--md-shadow-z2, 0 4px 12px rgba(0, 0, 0, 0.15));
 padding: 8px;
 z-index: 99999;
 border-radius: 4px;
 display: none;
}

.md-table-grid-cells-container {
 display: grid;
 grid-gap: 2px;
}

.md-table-grid-cell {
 width: 18px;
 height: 18px;
 background-color: var(--md-default-bg-color--light, #f0f0f0);
 border: 1px solid var(--md-default-fg-color--lightest, #ddd);
 cursor: pointer;
 box-sizing: border-box;
}

.md-table-grid-cell.highlighted {
 background-color: var(--md-accent-fg-color--transparent, #cce5ff);
 border-color: var(--md-accent-fg-color, #007bff);
}

.md-table-grid-label {
 text-align: center;
 margin-top: 8px;
 font-size: 13px;
 color: var(--md-default-fg-color--light, #555);
}

.md-contextual-table-toolbar {
 position: absolute;
 background-color: var(--md-default-bg-color, #fff);
 border: 1px solid var(--md-default-fg-color--lighter, #ccc);
 box-shadow: var(--md-shadow-z1, 0 2px 8px rgba(0, 0, 0, 0.15));
 padding: 5px;
 z-index: 99999;
 border-radius: 4px;
 display: none;
 gap: 3px;
 flex-wrap: nowrap;
}

.md-contextual-table-toolbar-button {
 padding: 4px 6px;
 border: 1px solid var(--md-default-fg-color--lighter, #ccc);
 background-color: var(--md-default-bg-color, #fff);
 border-radius: 3px;
 cursor: pointer;
 display: inline-flex;
 align-items: center;
 justify-content: center;
 min-width: 28px;
 min-height: 28px;
 transition: background-color 0.2s ease;
}

.md-contextual-table-toolbar-button:hover {
 background-color: var(--md-default-bg-color--lighter, #e9e9e9);
 border-color: var(--md-default-fg-color--lighter, #bbb);
}

.md-contextual-table-toolbar-button svg {
 width: 16px;
 height: 16px;
}

.md-image-dialog {
 padding: 20px;
 border: 1px solid var(--md-default-fg-color--lighter, #ccc);
 border-radius: 8px;
 min-width: 300px;
 box-shadow: var(--md-shadow-z2, 0 4px 12px rgba(0,0,0,0.15));
 background-color: var(--md-default-bg-color, #fff);
 color: var(--md-default-fg-color, #333);
}

.md-image-dialog::backdrop {
 background-color: rgba(0, 0, 0, 0.4);
}

.md-image-dialog-heading {
 margin-top: 0;
 margin-bottom: 15px;
 font-size: 1.2em;
 font-weight: bold;
 color: var(--md-default-fg-color, #333);
}

.md-image-dialog-label {
 display: block;
 margin-bottom: 5px;
 font-weight: normal;
 font-size: 14px;
 color: var(--md-default-fg-color--light, #555);
}

.md-image-dialog-input {
 width: 100%;
 padding: 8px 10px;
 margin-bottom: 15px;
 box-sizing: border-box;
 border: 1px solid var(--md-default-fg-color--lightest, #ddd);
 border-radius: 4px;
 font-size: 14px;
 background-color: var(--md-default-bg-color, #fff);
 color: var(--md-default-fg-color, #333);
}

.md-image-dialog-input:focus {
 border-color: var(--md-accent-fg-color, #007bff);
 outline: none;
 box-shadow: 0 0 0 0.2rem var(--md-accent-fg-color--transparent, rgba(0,123,255,.25));
}

.md-image-dialog-footer {
 text-align: right;
 margin-top: 20px;
 display: flex;
 justify-content: flex-end;
 gap: 10px;
}

.md-image-dialog-button {
 padding: 8px 15px;
 border: 1px solid var(--md-default-fg-color--lighter, #ccc);
 background-color: var(--md-default-bg-color--light, #f7f7f7);
 border-radius: 4px;
 cursor: pointer;
 font-size: 14px;
 transition: background-color 0.2s ease, border-color 0.2s ease;
 min-width: 80px;
}

.md-image-dialog-button:hover {
 background-color: var(--md-default-bg-color--lighter, #e9e9e9);
 border-color: var(--md-default-fg-color--lighter, #bbb);
}

.md-image-dialog-button-primary {
 background-color: var(--md-accent-fg-color, #007bff);
 color: white;
 border-color: var(--md-accent-fg-color, #007bff);
}

.md-image-dialog-button-primary:hover {
 background-color: var(--md-primary-fg-color--dark, #0056b3);
 border-color: var(--md-primary-fg-color--dark, #0056b3);
}

/* Material-style code blocks */
.md-editable-area .md-code-block {
 border-radius: 4px;
 overflow: hidden;
 margin-bottom: 1em;
 background-color: var(--md-code-bg-color, #f5f5f5);
 color: var(--md-code-fg-color, #24292e);
 border: 1px solid #373b41;
}

.md-editable-area .md-code-block pre {
 background-color: transparent;
 color: inherit;
 margin-bottom: 0;
 border-radius: 0;
 position: relative;
}

.md-editable-area .md-code-title {
 background-color: #1a1c1d;
 color: #c9d1d9;
 border-bottom: 1px solid #373b41;
 font-size: 0.8em;
 font-family: var(--md-code-font-family, 'Menlo', 'Consolas', monospace);
 padding: 6px 12px;
 border-bottom: 1px solid #3d3d3d;
 outline: none;
 cursor: text;
 min-height: 1.2em;
}

.md-editable-area .md-code-title:focus {
 border-bottom-color: var(--md-accent-fg-color, #007bff);
}

.md-editable-area .md-code-title:empty[data-placeholder]::before {
 content: attr(data-placeholder);
 color: #666;
 font-style: italic;
}

.md-editable-area .md-code-lang {
 background-color: #1a1c1d;
 color: #8b949e;
 font-size: 0.7em;
 font-family: var(--md-code-font-family, 'Menlo', 'Consolas', monospace);
 padding: 4px 12px;
 border-bottom: 1px solid #373b41;
 user-select: none;
 -webkit-user-select: none;
 text-transform: uppercase;
 letter-spacing: 0.5px;
 cursor: pointer;
}

.md-editable-area .md-code-lang:hover {
 color: #c9d1d9;
}

.md-editable-area .md-code-line-numbers {
 position: absolute;
 left: 0;
 top: 0;
 bottom: 0;
 display: flex;
 flex-direction: column;
 padding: 10px 0;
 text-align: right;
 user-select: none;
 -webkit-user-select: none;
 color: #8b949e;
 font-size: 0.85em;
 font-family: var(--md-code-font-family, 'Menlo', 'Consolas', monospace);
 border-right: 1px solid #e1e4e8;
 background-color: rgba(0,0,0,0.03);
}

.md-editable-area .md-code-line-numbers span {
 display: block;
 padding: 0 10px 0 8px;
 line-height: 1.45;
 cursor: pointer;
 min-width: 2.5em;
}

.md-editable-area .md-code-line-numbers span:hover {
 color: #24292e;
 background-color: rgba(0,0,0,0.06);
}

.md-editable-area .md-code-block pre[data-linenums] code {
 padding-left: 3.5em;
}

.md-editable-area .md-code-block pre code {
 background-color: transparent;
 color: inherit;
 display: block;
 font-size: .85em;
 line-height: 1.45;
 padding: .25em;
}

/* Lang button on basic (unwrapped) PRE blocks */
.md-editable-area pre .md-code-lang-btn {
 position: absolute;
 top: 4px;
 right: 4px;
 background: rgba(0,0,0,0.35);
 color: #c9d1d9;
 border: 1px solid rgba(255,255,255,0.12);
 border-radius: 3px;
 font-size: 0.65em;
 font-family: var(--md-code-font-family, 'Menlo', 'Consolas', monospace);
 padding: 2px 8px;
 cursor: pointer;
 text-transform: uppercase;
 letter-spacing: 0.5px;
 opacity: 0;
 transition: opacity 0.15s;
 z-index: 5;
 line-height: 1.4;
}

.md-editable-area pre:hover .md-code-lang-btn,
.md-editable-area pre:focus-within .md-code-lang-btn {
 opacity: 1;
}

.md-editable-area pre .md-code-lang-btn:hover {
 background: rgba(0,0,0,0.55);
 color: #fff;
}

/* Button group container for advanced code blocks (gear + lang) */
.md-editable-area .md-code-block .md-code-btn-group-advanced {
 position: absolute;
 top: 4px;
 right: 4px;
 display: flex;
 gap: 3px;
 align-items: center;
 z-index: 5;
 opacity: 0;
 transition: opacity 0.15s;
}

.md-editable-area .md-code-block:hover .md-code-btn-group-advanced,
.md-editable-area .md-code-block:focus-within .md-code-btn-group-advanced {
 opacity: 1;
}

/* Lang button on advanced (wrapped) code blocks */
.md-editable-area .md-code-block .md-code-lang-btn-advanced {
 background: rgba(0,0,0,0.35);
 color: #c9d1d9;
 border: 1px solid rgba(255,255,255,0.12);
 border-radius: 3px;
 font-size: 0.65em;
 font-family: var(--md-code-font-family, 'Menlo', 'Consolas', monospace);
 padding: 2px 8px;
 cursor: pointer;
 text-transform: uppercase;
 letter-spacing: 0.5px;
 line-height: 1.4;
}

.md-editable-area .md-code-block .md-code-lang-btn-advanced:hover {
 background: rgba(0,0,0,0.55);
 color: #fff;
}

/* Language dropdown menu — appended to body so it escapes overflow:hidden parents */
.md-code-lang-dropdown {
 position: fixed;
 width: 180px;
 max-height: 240px;
 background: #1e1e1e;
 border: 1px solid #444;
 border-radius: 4px;
 box-shadow: 0 4px 12px rgba(0,0,0,0.4);
 z-index: 99999;
 display: flex;
 flex-direction: column;
 overflow: hidden;
}

.md-code-lang-filter {
 width: 100%;
 padding: 6px 8px;
 border: none;
 border-bottom: 1px solid #444;
 background: #2a2a2a;
 color: #c9d1d9;
 font-size: 0.8em;
 font-family: var(--md-code-font-family, 'Menlo', 'Consolas', monospace);
 outline: none;
 box-sizing: border-box;
}

.md-code-lang-filter::placeholder {
 color: #666;
}

.md-code-lang-list {
 overflow-y: auto;
 max-height: 200px;
}

.md-code-lang-item {
 padding: 4px 8px;
 cursor: pointer;
 color: #c9d1d9;
 font-size: 0.8em;
 font-family: var(--md-code-font-family, 'Menlo', 'Consolas', monospace);
}

.md-code-lang-item:hover {
 background: #333;
}

.md-code-lang-item-active {
 background: #264f78;
 color: #fff;
}

/* Settings gear button on basic (unwrapped) PRE blocks */
.md-editable-area pre .md-code-settings-btn {
 position: absolute;
 top: 4px;
 right: 52px;
 background: rgba(0,0,0,0.35);
 color: #c9d1d9;
 border: 1px solid rgba(255,255,255,0.12);
 border-radius: 3px;
 font-size: 0.65em;
 padding: 2px 4px;
 cursor: pointer;
 opacity: 0;
 transition: opacity 0.15s;
 z-index: 5;
 line-height: 1;
 display: flex;
 align-items: center;
 justify-content: center;
}

.md-editable-area pre:hover .md-code-settings-btn,
.md-editable-area pre:focus-within .md-code-settings-btn {
 opacity: 1;
}

.md-editable-area pre .md-code-settings-btn:hover {
 background: rgba(0,0,0,0.55);
 color: #fff;
}

/* Settings gear button on advanced (wrapped) code blocks */
.md-editable-area .md-code-block .md-code-settings-btn-advanced {
 background: rgba(0,0,0,0.35);
 color: #c9d1d9;
 border: 1px solid rgba(255,255,255,0.12);
 border-radius: 3px;
 font-size: 0.65em;
 padding: 2px 4px;
 cursor: pointer;
 line-height: 1;
 display: flex;
 align-items: center;
 justify-content: center;
}

.md-editable-area .md-code-block .md-code-settings-btn-advanced:hover {
 background: rgba(0,0,0,0.55);
 color: #fff;
}

/* Settings dropdown menu */
.md-code-settings-dropdown {
 position: fixed;
 width: 200px;
 background: #1e1e1e;
 border: 1px solid #444;
 border-radius: 4px;
 box-shadow: 0 4px 12px rgba(0,0,0,0.4);
 z-index: 99999;
 padding: 6px 0;
 font-family: var(--md-code-font-family, 'Menlo', 'Consolas', monospace);
 font-size: 0.75em;
 color: #c9d1d9;
}

.md-code-settings-row {
 display: flex;
 align-items: center;
 justify-content: space-between;
 padding: 5px 10px;
}

.md-code-settings-label {
 flex-shrink: 0;
 margin-right: 8px;
}

.md-code-settings-toggle {
 background: #333;
 color: #888;
 border: 1px solid #555;
 border-radius: 3px;
 padding: 2px 10px;
 cursor: pointer;
 font-family: inherit;
 font-size: inherit;
 transition: background 0.1s, color 0.1s;
}

.md-code-settings-toggle.active {
 background: #264f78;
 color: #fff;
 border-color: #3a7bd5;
}

.md-code-settings-toggle:hover {
 background: #444;
 color: #fff;
}

.md-code-settings-toggle.active:hover {
 background: #2d5a8a;
}

.md-code-settings-btn-group {
 display: flex;
 gap: 2px;
}

.md-code-settings-opt {
 background: #333;
 color: #888;
 border: 1px solid #555;
 border-radius: 3px;
 padding: 2px 8px;
 cursor: pointer;
 font-family: inherit;
 font-size: inherit;
 transition: background 0.1s, color 0.1s;
}

.md-code-settings-opt.active {
 background: #264f78;
 color: #fff;
 border-color: #3a7bd5;
}

.md-code-settings-opt:hover {
 background: #444;
 color: #fff;
}

.md-code-settings-opt.active:hover {
 background: #2d5a8a;
}

/* Admonition settings gear button */
.md-editable-area .admonition .md-admonition-settings-btn,
.md-editable-area details[class] .md-admonition-settings-btn {
 position: absolute;
 top: 6px;
 right: 6px;
 background: rgba(0,0,0,0.08);
 color: #666;
 border: 1px solid rgba(0,0,0,0.12);
 border-radius: 3px;
 font-size: 0.65em;
 padding: 2px 4px;
 cursor: pointer;
 opacity: 0;
 transition: opacity 0.15s;
 z-index: 5;
 line-height: 1;
 display: flex;
 align-items: center;
 justify-content: center;
}

.md-editable-area .admonition:hover > .md-admonition-settings-btn,
.md-editable-area .admonition:focus-within > .md-admonition-settings-btn,
.md-editable-area details[class]:hover > .md-admonition-settings-btn,
.md-editable-area details[class]:focus-within > .md-admonition-settings-btn {
 opacity: 1;
}

.md-editable-area .admonition .md-admonition-settings-btn:hover,
.md-editable-area details[class] .md-admonition-settings-btn:hover {
 background: rgba(0,0,0,0.18);
 color: #333;
}

/* Admonition settings dropdown */
.md-admonition-settings-dropdown {
 position: fixed;
 width: 210px;
 background: #1e1e1e;
 border: 1px solid #444;
 border-radius: 4px;
 box-shadow: 0 4px 12px rgba(0,0,0,0.4);
 z-index: 99999;
 padding: 6px 0;
 font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
 font-size: 12px;
 color: #c9d1d9;
}

.md-admonition-settings-row {
 display: flex;
 align-items: center;
 justify-content: space-between;
 padding: 5px 10px;
}

.md-admonition-settings-label {
 flex-shrink: 0;
 margin-right: 8px;
}

.md-admonition-type-select {
 flex: 1;
 min-width: 0;
 background: #333;
 color: #c9d1d9;
 border: 1px solid #555;
 border-radius: 3px;
 padding: 2px 6px;
 font-family: inherit;
 font-size: inherit;
 cursor: pointer;
}

.md-admonition-type-select:hover {
 background: #444;
}

.md-admonition-type-select:focus {
 outline: none;
 border-color: #3a7bd5;
}

.md-admonition-settings-toggle {
 background: #333;
 color: #888;
 border: 1px solid #555;
 border-radius: 3px;
 padding: 2px 10px;
 cursor: pointer;
 font-family: inherit;
 font-size: inherit;
 transition: background 0.1s, color 0.1s;
}

.md-admonition-settings-toggle.active {
 background: #264f78;
 color: #fff;
 border-color: #3a7bd5;
}

.md-admonition-settings-toggle:hover {
 background: #444;
 color: #fff;
}

.md-admonition-settings-toggle.active:hover {
 background: #2d5a8a;
}

/* Placement button group */
.md-admonition-placement-group {
 display: flex;
 flex-direction: column;
 gap: 2px;
 width: 100%;
 padding: 5px 10px;
}

.md-admonition-placement-full {
 display: block;
 width: 100%;
 background: #333;
 color: #888;
 border: 1px solid #555;
 border-radius: 3px;
 padding: 4px 0;
 cursor: pointer;
 font-family: inherit;
 font-size: inherit;
 text-align: center;
 transition: background 0.1s, color 0.1s;
}

.md-admonition-placement-full.active {
 background: #264f78;
 color: #fff;
 border-color: #3a7bd5;
}

.md-admonition-placement-full:hover {
 background: #444;
 color: #fff;
}

.md-admonition-placement-full.active:hover {
 background: #2d5a8a;
}

.md-admonition-placement-halves {
 display: flex;
 gap: 2px;
}

.md-admonition-placement-half {
 flex: 1;
 background: #333;
 color: #888;
 border: 1px solid #555;
 border-radius: 3px;
 padding: 4px 0;
 cursor: pointer;
 font-family: inherit;
 font-size: inherit;
 text-align: center;
 transition: background 0.1s, color 0.1s;
}

.md-admonition-placement-half.active {
 background: #264f78;
 color: #fff;
 border-color: #3a7bd5;
}

.md-admonition-placement-half:hover {
 background: #444;
 color: #fff;
}

.md-admonition-placement-half.active:hover {
 background: #2d5a8a;
}

/* Link settings dropdown - matches admonition/code settings style */
.md-link-settings-dropdown {
 position: fixed;
 width: 220px;
 background: #1e1e1e;
 border: 1px solid #444;
 border-radius: 4px;
 box-shadow: 0 4px 12px rgba(0,0,0,0.4);
 z-index: 99999;
 padding: 6px 0;
 font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
 font-size: 12px;
 color: #c9d1d9;
}

.md-link-settings-row {
 display: flex;
 align-items: center;
 justify-content: space-between;
 padding: 5px 10px;
}

.md-link-settings-label {
 flex-shrink: 0;
 margin-right: 8px;
}

.md-link-settings-input {
 flex: 1;
 min-width: 0;
 background: #333;
 color: #c9d1d9;
 border: 1px solid #555;
 border-radius: 3px;
 padding: 4px 8px;
 font-family: inherit;
 font-size: inherit;
}

.md-link-settings-input:focus {
 outline: none;
 border-color: #3a7bd5;
}

.md-link-settings-input::placeholder {
 color: #888;
}

.md-link-settings-apply-row {
 justify-content: flex-end;
 padding-top: 8px;
}

.md-link-settings-apply {
 background: #264f78;
 color: #fff;
 border: 1px solid #3a7bd5;
 border-radius: 3px;
 padding: 4px 12px;
 cursor: pointer;
 font-family: inherit;
 font-size: inherit;
 transition: background 0.1s, color 0.1s;
}

.md-link-settings-apply:hover {
 background: #2d5a8a;
}

/* Image insertion dropdown - matches link settings style */
.md-image-insert-dropdown {
 position: fixed;
 width: 260px;
 background: #1e1e1e;
 border: 1px solid #444;
 border-radius: 4px;
 box-shadow: 0 4px 12px rgba(0,0,0,0.4);
 z-index: 99999;
 padding: 6px 0;
 font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
 font-size: 12px;
 color: #c9d1d9;
}

.md-image-insert-row {
 display: flex;
 align-items: center;
 justify-content: space-between;
 padding: 5px 10px;
}

.md-image-insert-label {
 flex-shrink: 0;
 margin-right: 8px;
 min-width: 30px;
}

.md-image-insert-input {
 flex: 1;
 min-width: 0;
 background: #333;
 color: #c9d1d9;
 border: 1px solid #555;
 border-radius: 3px;
 padding: 4px 8px;
 font-family: inherit;
 font-size: inherit;
}

.md-image-insert-input:focus {
 outline: none;
 border-color: #3a7bd5;
}

.md-image-insert-input::placeholder {
 color: #888;
}

.md-image-insert-slider {
 flex: 1;
 min-width: 0;
 accent-color: #3a7bd5;
}

.md-image-insert-pct {
 min-width: 36px;
 text-align: right;
 color: #888;
 font-size: 11px;
 margin-left: 6px;
}

.md-image-insert-apply-row {
 justify-content: flex-end;
 padding-top: 8px;
}

.md-image-insert-apply {
 background: #264f78;
 color: #fff;
 border: 1px solid #3a7bd5;
 border-radius: 3px;
 padding: 4px 12px;
 cursor: pointer;
 font-family: inherit;
 font-size: inherit;
 transition: background 0.1s, color 0.1s;
}

.md-image-insert-apply:hover {
 background: #2d5a8a;
}

.md-image-autocomplete {
 max-height: 200px;
 overflow-y: auto;
 border-top: 1px solid #333;
}

.md-image-ac-item {
 display: flex;
 flex-direction: column;
 padding: 5px 10px;
 cursor: pointer;
 gap: 1px;
}

.md-image-ac-item:hover,
.md-image-ac-item-selected {
 background: #264f78;
}

.md-image-ac-item-name {
 color: #c9d1d9;
 font-size: 12px;
 white-space: nowrap;
 overflow: hidden;
 text-overflow: ellipsis;
}

.md-image-ac-item-path {
 color: #888;
 font-size: 10px;
 white-space: nowrap;
 overflow: hidden;
 text-overflow: ellipsis;
}

/* Image wrapper and gear in editable area */
.md-image-wrapper {
 position: relative;
 display: inline-block;
 line-height: 0;
}

.md-image-wrapper img {
 display: block;
}

.md-image-settings-btn {
 position: absolute;
 top: 4px;
 right: 4px;
 background: rgba(0,0,0,0.45);
 color: #c9d1d9;
 border: 1px solid rgba(255,255,255,0.15);
 border-radius: 3px;
 font-size: 0.65em;
 cursor: pointer;
 opacity: 0;
 transition: opacity 0.15s;
 z-index: 2;
 padding: 2px 4px;
 display: flex;
 align-items: center;
 justify-content: center;
}

.md-image-wrapper:hover .md-image-settings-btn,
.md-image-wrapper:focus-within .md-image-settings-btn {
 opacity: 1;
}

.md-image-settings-btn:hover {
 background: rgba(0,0,0,0.65);
 color: #fff;
}

/* Image gear dropdown */
.md-image-gear-dropdown {
 position: fixed;
 width: 240px;
 background: #1e1e1e;
 border: 1px solid #444;
 border-radius: 4px;
 box-shadow: 0 4px 12px rgba(0,0,0,0.4);
 z-index: 99999;
 padding: 6px 0;
 font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
 font-size: 12px;
 color: #c9d1d9;
}

.md-image-gear-row {
 display: flex;
 align-items: center;
 justify-content: space-between;
 padding: 5px 10px;
}

.md-image-gear-label {
 flex-shrink: 0;
 margin-right: 8px;
}

.md-image-gear-input {
 flex: 1;
 min-width: 0;
 background: #333;
 color: #c9d1d9;
 border: 1px solid #555;
 border-radius: 3px;
 padding: 4px 8px;
 font-family: inherit;
 font-size: inherit;
}

.md-image-gear-input:focus {
 outline: none;
 border-color: #3a7bd5;
}

.md-image-gear-input::placeholder {
 color: #888;
}

.md-image-gear-dims {
 color: #888;
 font-size: 11px;
}

.md-image-gear-cb-label {
 display: flex;
 align-items: center;
 gap: 6px;
 cursor: pointer;
 font-size: 11px;
 color: #c9d1d9;
}

.md-image-gear-cb {
 accent-color: #3a7bd5;
}

.md-image-gear-btn {
 background: #264f78;
 color: #fff;
 border: 1px solid #3a7bd5;
 border-radius: 3px;
 padding: 3px 8px;
 cursor: pointer;
 font-family: inherit;
 font-size: 11px;
 transition: background 0.1s;
 white-space: nowrap;
}

.md-image-gear-btn:hover {
 background: #2d5a8a;
}

.md-image-gear-btn-row {
 display: flex;
 gap: 6px;
 flex-wrap: wrap;
 padding: 6px 10px 4px;
}

/* Image resize selection */
.md-image-selected {
 outline: 2px solid var(--md-accent-fg-color, #448aff);
 outline-offset: 1px;
}

.md-image-resize-container {
 position: absolute;
 top: 0;
 left: 0;
 right: 0;
 bottom: 0;
 pointer-events: none;
}

.md-image-resize-handle {
 position: absolute;
 width: 10px;
 height: 10px;
 background: var(--md-accent-fg-color, #448aff);
 border: 1px solid #fff;
 border-radius: 2px;
 pointer-events: all;
 z-index: 3;
}

.md-image-resize-handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.md-image-resize-handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.md-image-resize-handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.md-image-resize-handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }

.md-image-dimension-label {
 position: absolute;
 top: 50%;
 left: 50%;
 transform: translate(-50%, -50%);
 background: rgba(0,0,0,0.65);
 color: #fff;
 font-size: 33px;
 line-height: 1.2;
 padding: 12px 24px;
 border-radius: 8px;
 white-space: nowrap;
 pointer-events: none;
 z-index: 3;
}
