/* Shared button metrics keep Visual and Markdown formatting controls aligned. */
.workspace-content .markdown-tools{gap:3px;margin:0 0 10px;padding:5px 0 7px}
.workspace-content .markdown-tools .format-button{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;flex:0 0 30px;width:30px;min-width:30px;height:30px;padding:0;margin:0;border:0;border-radius:5px;font:600 12px/1 system-ui;letter-spacing:normal}
.workspace-content .markdown-tools .format-bold{font-weight:800}
.workspace-content .markdown-tools .format-italic{font-style:italic}
.workspace-content .markdown-tools .format-redo,.workspace-content .markdown-tools .format-outdent{box-shadow:2px 0 0 -1px var(--line)}
/* All three editor modes own their scrolling; tabs and toolbars stay in place. */
.workspace{height:100dvh;min-height:0;overflow:hidden}.workspace>main{height:100dvh;min-height:0;overflow:hidden}
.workspace .workspace-content{flex:1;min-height:0;overflow:hidden}.workspace .workspace-content>.collection{overflow:auto;min-height:0}.workspace .workspace-content>.graph-view{overflow:hidden;min-height:0}
.workspace .workspace-content>.editor{height:100%;min-height:0;overflow:hidden;display:flex;flex-direction:column}
.workspace .workspace-content .editor-body{flex:1;min-height:0;overflow:hidden;display:flex;flex-direction:column}
.workspace-content .editor-toolbar,.workspace-content .markdown-tools,.workspace-content .editor-footer{flex-shrink:0}
.workspace .workspace-content .markdown-editor,.workspace .workspace-content .editor-preview-scroll{flex:1;min-height:0;height:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;resize:none;padding-bottom:28px}
.visual-editor-host{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}.visual-formatbar{flex-shrink:0}.visual-formatbar[hidden]{display:none}
.visual-surface{flex:1;min-height:0;height:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;outline:none;padding:5px 8px 32px 0;white-space:pre-wrap;overflow-wrap:anywhere;font-size:var(--note-font-size,14px);line-height:var(--note-line-height,1.9);color:#586b85}
.visual-surface:focus-visible{outline:none}.visual-line{min-height:calc(var(--note-line-height, 1.9) * 1em);position:relative}.visual-line[data-kind="quote"]{border-left:3px solid #b4c9ec;padding-left:8px;color:#8297b4;margin:0}
.visual-surface>.visual-line[data-kind="quote"]:first-child,.visual-surface>:not([data-kind="quote"])+.visual-line[data-kind="quote"],.visual-surface>.visual-line[data-kind="quote"]+:not([data-kind="quote"]){margin-top:7px}
.visual-line[data-kind="list"]{padding-left:18px;margin-left:var(--list-indent,0px)}.visual-line[data-kind="list"][data-marker="•"]{padding-left:14px}.visual-line[data-kind="task"]{padding-left:24px;margin-left:var(--list-indent,0px)}.visual-line[data-kind="list"]:before,.visual-line[data-kind="task"]:before{content:attr(data-marker);position:absolute;left:1px;color:#6885af;user-select:none}.visual-line[data-kind="task"]:before{cursor:pointer}
.visual-line[data-kind="code"],.visual-opaque{font-family:Consolas,monospace;background:#f3f6fa;border-radius:5px;padding:8px 12px;white-space:pre-wrap}.visual-surface code{font-family:Consolas,monospace;background:#edf2f8;border-radius:3px;padding:1px 4px}.visual-token{color:#557bb2;background:#f1f5fc;border-radius:3px}.visual-surface a{color:#4278cc;text-decoration:underline}.visual-surface table{border-collapse:collapse;width:100%;margin:10px 0}.visual-surface td,.visual-surface th{border:1px solid #dce5f2;padding:7px 10px}.visual-surface th{background:#f3f6fa}
.visual-link-form{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:10px 0;flex-shrink:0}.visual-link-form[hidden]{display:none}.visual-link-form input{min-width:100px;flex:1;border:1px solid #dce5f2;border-radius:6px;padding:7px;font-size:12px}.visual-link-form button{padding:7px 10px;border-radius:6px;font-size:11px}.visual-editor-message{font-size:11px;color:#9a734a;margin:3px 0;flex-shrink:0}.visual-editor-message:empty{display:none}

/* Table controls are shown only while editing that table. */
.visual-table-frame{position:relative;display:grid;grid-template-columns:minmax(0,1fr) 22px;grid-template-rows:auto minmax(0,auto) 22px;gap:3px;width:max-content;max-width:100%;margin:30px 0 22px;white-space:normal;line-height:1.5}
.visual-table-viewport{grid-column:1;grid-row:2;min-width:0;overflow-x:auto;border:1px solid #dce3ec;border-radius:5px;background:#fff}
.visual-surface .visual-table{width:max-content;min-width:100%;table-layout:fixed;border-collapse:separate;border-spacing:0;margin:0;border:0;border-radius:0;white-space:normal}
.visual-surface .visual-table th,.visual-surface .visual-table td{box-sizing:border-box;width:190px;min-width:140px;min-height:34px;height:34px;border:0;border-right:1px solid #e3e8ef;border-bottom:1px solid #e3e8ef;padding:7px 12px;vertical-align:top;font-family:inherit;font-size:inherit;line-height:1.5;text-align:left;white-space:pre-wrap;overflow-wrap:anywhere;background:#fff;color:inherit;font-weight:400;cursor:text}
.visual-surface .visual-table th{background:#f7f8fa;color:#44546a;font-weight:600}
.visual-surface .visual-table tr:last-child td{border-bottom:0}
.visual-surface .visual-table th:last-child,.visual-surface .visual-table td:last-child{border-right:0}
.visual-surface .visual-table td:hover{background:#fcfdff}
.visual-surface .visual-table th:focus,.visual-surface .visual-table td:focus{position:relative;outline:2px solid #86a8df;outline-offset:-2px;background:#fafcff}
.visual-table-frame .table-add-row,.visual-table-frame .table-add-column{display:flex;align-items:center;justify-content:center;min-width:0;min-height:0;padding:0;border:0;border-radius:4px;background:#f3f5f8;color:#8a96a8;font:400 17px/1 system-ui;cursor:pointer;transition:background .15s,color .15s}
.visual-table-frame .table-add-column{grid-column:2;grid-row:2;width:22px;align-self:stretch}
.visual-table-frame .table-add-row{grid-column:1;grid-row:3;height:22px}
.visual-table-frame .table-add-row:hover,.visual-table-frame .table-add-column:hover{background:#e8effb;color:#3e72bd}
.visual-table-frame button:focus-visible{outline:2px solid #5988dc;outline-offset:2px}
.visual-table-frame button:disabled{opacity:.35;cursor:default}
.visual-table-frame:not(.is-active) .table-add-row,.visual-table-frame:not(.is-active) .table-add-column{visibility:hidden;pointer-events:none}
.visual-table-tools{grid-column:1/-1;grid-row:1;min-width:0;padding:0 0 5px;white-space:normal;font:400 12px/1.4 system-ui}
.visual-table-tools[hidden]{display:none}
.visual-table-menu{display:flex;align-items:center;flex-wrap:wrap;gap:3px;padding:4px;border:1px solid #e2e8f0;border-radius:6px;background:#f8fafc;width:fit-content;max-width:100%}
.visual-table-menu button{display:block;padding:5px 8px;border:0;border-radius:4px;background:transparent;color:#52647c;font:400 11px/1.4 system-ui;text-align:left;cursor:pointer;white-space:nowrap}
.visual-table-menu button:hover:not(:disabled){background:#e9f0fb;color:#3f6eb1}
.visual-table-menu button.destructive{color:#b35e62}
.visual-table-menu button[data-table-action="left"]{border-left:1px solid #dfe6ef;border-radius:0;padding-left:10px;margin-left:3px}
@media(max-width:600px){.visual-table-frame{width:100%}.visual-surface .visual-table th,.visual-surface .visual-table td{width:145px;min-width:120px}}

.block-style-picker{position:relative;flex:0 0 auto;margin-right:5px;color:#526781;font:500 12px/1.4 system-ui;z-index:12}
.block-style-picker summary{box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:130px;height:30px;padding:0 9px;border:1px solid var(--line);border-radius:5px;background:#fff;cursor:pointer;list-style:none;user-select:none}
.block-style-picker summary::-webkit-details-marker{display:none}
.block-style-picker summary:hover,.block-style-picker[open] summary{background:#f3f7fd;border-color:#bdcfea}
.block-style-picker .block-style-label{min-width:0;line-height:1.4}
.block-style-picker .style-chevron{display:block;width:16px;height:16px;flex:0 0 16px;color:#8193ad;transition:transform .15s ease}
.block-style-picker[open] .style-chevron{transform:rotate(180deg)}
@media(prefers-reduced-motion:reduce){.block-style-picker .style-chevron{transition:none}}
.block-style-menu{position:absolute;top:calc(100% + 6px);left:0;display:flex;flex-direction:column;width:224px;max-width:calc(100vw - 50px);max-height:min(430px,60vh);overflow-y:auto;padding:5px;border:1px solid #dce5f2;border-radius:8px;background:#fff;box-shadow:0 8px 28px #233e6524}
.block-style-picker:not([open]) .block-style-menu{display:none}
.workspace-content .markdown-tools .block-style-option{display:flex;align-items:center;width:100%;min-height:36px;padding:8px 12px;border:0;border-radius:5px;background:transparent;color:#526781;text-align:left;line-height:1.35;font-family:inherit;cursor:pointer}
.workspace-content .markdown-tools .block-style-option:hover:not(:disabled){background:#edf3ff;color:#3b70bc}
.block-style-picker summary:focus-visible,.block-style-option:focus-visible{outline:2px solid #5988dc;outline-offset:-2px}
.block-style-option:disabled{opacity:.4;cursor:default}

.workspace-content .markdown-tools .block-style-option.is-selected{background:#edf3ff;color:#3b70bc}
.block-style-option.is-selected::after{content:'✓';margin-left:auto;padding-left:16px;font:600 13px system-ui;color:#477ed6}

/* Insert dropdown menu in Visual and Markdown toolbars */
.insert-menu-picker{position:relative;flex:0 0 auto;margin-left:4px;color:#526781;font:500 12px/1.4 system-ui;z-index:12}
.insert-menu-picker summary{box-sizing:border-box;display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 9px;border:1px solid var(--line);border-radius:5px;background:#fff;cursor:pointer;list-style:none;user-select:none;transition:background .14s,border-color .14s,color .14s}
.insert-menu-picker summary::-webkit-details-marker{display:none}
.insert-menu-picker summary:hover,.insert-menu-picker[open] summary{background:#f3f7fd;border-color:#bdcfea;color:#3b70bc}
.insert-menu-picker summary .lucide-icon{width:15px;height:15px;flex-shrink:0}
.insert-menu-picker .style-chevron{display:block;width:15px;height:15px;flex:0 0 15px;color:#8193ad;transition:transform .15s ease}
.insert-menu-picker[open] .style-chevron{transform:rotate(180deg)}
.insert-menu-dropdown{position:absolute;top:calc(100% + 6px);left:0;display:flex;flex-direction:column;width:230px;max-width:calc(100vw - 40px);max-height:min(380px,60vh);overflow-y:auto;padding:5px;border:1px solid #dce5f2;border-radius:8px;background:#fff;box-shadow:0 8px 28px #233e6524}
.insert-menu-picker:not([open]) .insert-menu-dropdown{display:none}
.workspace-content .markdown-tools .insert-menu-option{display:flex;align-items:center;gap:9px;width:100%;min-height:34px;padding:7px 10px;border:0;border-radius:5px;background:transparent;color:#526781;font:500 12px/1.35 system-ui;text-align:left;cursor:pointer}
.workspace-content .markdown-tools .insert-menu-option:hover:not(:disabled){background:#edf3ff;color:#3b70bc}
.workspace-content .markdown-tools .insert-menu-option:disabled{opacity:.4;cursor:default}
.insert-menu-icon{display:grid;place-items:center;width:16px;height:16px;flex-shrink:0;color:#64748b}
.insert-menu-option:hover .insert-menu-icon{color:#3b70bc}
.insert-option-youtube .insert-menu-icon{color:#dc2626}
.insert-menu-icon svg{width:15px;height:15px}
.visual-token.visual-wikilink{color:#4278cc;background:transparent;text-decoration:underline;cursor:pointer}
.visual-token.visual-wikilink:hover{background:#e8f0ff}
.visual-token.visual-wikilink:focus-visible{outline:2px solid #5988dc;outline-offset:1px}
.markdown-tools[inert]{opacity:.45;cursor:default}
/* #tag badges (Visual and Preview): a soft pill, like Obsidian's tags. Colours come from --tag-bg / --tag-fg in style.css. */
.visual-tag,.note-tag{display:inline-block;margin:0 1px;padding:0 9px;border-radius:999px;background:var(--tag-bg,#e8f0ff);color:var(--tag-fg,#3b70bc);font-size:.92em;font-weight:500;line-height:1.55;white-space:nowrap;cursor:default;vertical-align:baseline}
.visual-tag:hover,.note-tag:hover{background:var(--tag-bg-hover,#d9e6fc)}
/* Images from the workspace, in Visual and Preview. */
.visual-token.visual-image{display:inline-block;max-width:100%;padding:0;background:transparent;line-height:0;vertical-align:bottom;border-radius:6px;cursor:default}
.visual-token.visual-image:focus-visible{outline:2px solid #5988dc;outline-offset:2px}
/* Default size is capped at 480px high; an explicit width (from the alt text) lifts the cap so the image can really grow. */
.visual-image img,.preview-image img{display:block;max-width:100%;max-height:480px;border-radius:6px}
.preview-image{display:inline-block;max-width:100%;vertical-align:bottom}
.preview-image.is-broken,.visual-token.is-broken-image{color:#b3563f;background:#fdf2ee;border-radius:4px}
/* Alignment from the alt text (![alt|300|center](path)): the image becomes its own block. */
.visual-token.visual-image[data-align]{display:block;width:fit-content;max-width:100%}
.visual-token.visual-image[data-align="center"]{margin-inline:auto}
.visual-token.visual-image[data-align="right"]{margin-left:auto}
.visual-token.visual-image[data-align="left"]{margin-right:auto}
.preview-image[data-align]{display:block}
.preview-image[data-align="center"] img{margin-inline:auto}
.preview-image[data-align="right"] img{margin-left:auto}
/* Selected image in Visual: frame, resize handle and options bar (outside the editable text). */
.image-overlay{position:fixed;inset:0;z-index:25;pointer-events:none}
.image-overlay[hidden]{display:none}
.image-frame{position:absolute;box-sizing:border-box;border:2px solid rgba(89,136,220,.7);border-radius:6px;pointer-events:none}
.image-handle{position:absolute;right:-7px;bottom:-7px;width:12px;height:12px;box-sizing:border-box;border:2px solid #fff;border-radius:3px;background:#5988dc;cursor:nwse-resize;pointer-events:auto;touch-action:none}
.image-bar{position:absolute;display:flex;align-items:center;gap:3px;padding:5px;border:1px solid #dce5f2;border-radius:10px;background:#fff;box-shadow:0 8px 28px #233e6524;color:#526781;font:500 11px/1.2 system-ui,sans-serif;pointer-events:auto}
.image-bar button{display:grid;place-items:center;min-width:28px;height:28px;padding:0 6px;border:0;border-radius:6px;background:transparent;color:inherit;font:inherit;cursor:pointer}
.image-bar button:hover{background:#edf3ff;color:#3b70bc}
.image-bar button[aria-pressed="true"]{background:#e3ecfb;color:#3b70bc}
.image-bar button.image-remove:hover{background:#fdecec;color:#b34747}
.image-bar .lucide-icon{width:15px;height:15px}
.image-bar .image-sep{width:1px;height:18px;margin:0 3px;background:#e3e9f3}
.image-bar input{width:150px;height:28px;box-sizing:border-box;padding:0 8px;border:1px solid #dbe4f1;border-radius:6px;background:#f7f9fd;color:#344155;font:inherit}
.image-bar input:focus,.image-bar input:focus-visible{outline:0;border-color:#c3d0e3;background:#fff}
@media(max-width:600px){.image-bar input{width:100px}}

/* YouTube video embeds (Visual editor and Preview) */
.youtube-embed,
.visual-youtube {
    position: relative;
    display: block;
    width: 680px;
    max-width: 100%;
    margin: 10px 0;
    border: 2px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    background: #020617;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.visual-youtube.is-selected {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.22), 0 4px 16px rgba(15, 23, 42, 0.18);
}

.youtube-embed[data-align="left"],
.visual-youtube[data-align="left"] {
    margin-left: 0;
    margin-right: auto;
}

.youtube-embed[data-align="center"],
.visual-youtube[data-align="center"] {
    margin-left: auto;
    margin-right: auto;
}

.youtube-embed[data-align="right"],
.visual-youtube[data-align="right"] {
    margin-left: auto;
    margin-right: 0;
}

.visual-youtube.is-resizing iframe {
    pointer-events: none;
}

.youtube-embed-head {
    display: none;
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    z-index: 4;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid #dce5f2;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.22);
    color: #334155;
    font-size: 12px;
}

.visual-youtube.is-selected .youtube-embed-head {
    display: flex;
}

.youtube-btn-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    background: #f1f5f9;
}

.youtube-embed-btn.is-compact {
    padding: 1px 6px;
    border: 0;
    background: transparent;
    color: #475569;
    font-size: 10.5px;
}

.youtube-embed-btn.is-compact[aria-pressed="true"] {
    background: #ffffff;
    color: #2563eb;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

.youtube-resize-handle {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 10px;
    cursor: ew-resize;
    z-index: 5;
    background: transparent;
    transition: background 0.14s;
}

.visual-youtube.is-selected .youtube-resize-handle {
    display: block;
}

.youtube-resize-handle:hover,
.visual-youtube.is-resizing .youtube-resize-handle {
    background: rgba(56, 189, 248, 0.45);
}

.youtube-embed-icon {
    width: 15px;
    height: 15px;
    color: #dc2626;
    flex-shrink: 0;
}

.youtube-embed-title {
    flex: 1;
    min-width: 0;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.youtube-embed-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.youtube-embed-btn,
.visual-surface a.youtube-embed-btn {
    padding: 2px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #334155;
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.14s, border-color 0.14s, color 0.14s;
}

.youtube-embed-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
}

.youtube-embed-btn.is-danger:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #b91c1c;
}

.youtube-frame {
    display: block;
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #020617;
}

.youtube-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.youtube-embed-link {
    display: block;
    padding: 6px 10px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    color: #2563eb;
    font-size: 12px;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.youtube-embed-link:hover {
    text-decoration: underline;
}
