/* markdown.org tools — Markdown workspace: file tree | the Markdown editor (editor.js, embedded) */
.ws { position: relative; }
.ws-body { display: grid; grid-template-columns: minmax(190px, 250px) minmax(0, 1fr); height: 78vh; min-height: 480px; }

/* file tree */
.ws-tree-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--surface-soft); }
.ws-tree-pane.ws-drop-root { box-shadow: inset 0 0 0 2px var(--accent); }
.ws-tree-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.ws-tree-title { flex: 1 1 auto; font-weight: 700; font-size: 0.9rem; color: var(--heading); }
.ws-tree { flex: 1 1 auto; overflow: auto; margin: 0; padding: 6px 0; list-style: none; font-size: 0.9rem; }
.ws-tree ul { margin: 0; padding: 0; list-style: none; }
.ws-tree li { margin: 0; }
.ws-row { display: flex; align-items: center; gap: 5px; min-height: 30px; padding-right: 6px; cursor: pointer; color: var(--fg); border-radius: 6px; margin: 0 6px; user-select: none; outline: 0; }
.ws-row:hover { background: rgba(59, 110, 246, 0.08); }
.ws-row:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.ws-row.is-open { background: var(--accent); color: #fff; }
.ws-row.is-dir-current:not(.is-open) .ws-name { font-weight: 700; }
.ws-row.ws-drop-into { background: var(--accent-tint); box-shadow: inset 0 0 0 2px var(--accent); }
.ws-row.is-dragging { opacity: 0.45; }
.ws-caret { flex: 0 0 12px; width: 12px; height: 12px; position: relative; }
.ws-caret::before { content: ""; position: absolute; left: 3px; top: 2px; border: 4px solid transparent; border-left: 5px solid currentColor; border-right: 0; opacity: 0.6; transition: transform 0.12s; transform-origin: 2px 4px; }
[aria-expanded="true"] > .ws-row > .ws-caret::before { transform: rotate(90deg); }
.ws-caret-none::before { display: none; }
.ws-icon { flex: 0 0 16px; display: inline-flex; color: var(--accent); }
.ws-row.is-open .ws-icon { color: #fff; }
.ws-icon svg { width: 16px; height: 16px; }
.ws-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-row-tools { display: none; gap: 2px; }
.ws-row:hover .ws-row-tools, .ws-row:focus-within .ws-row-tools { display: inline-flex; }
.ws-tool { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 5px; background: none; color: inherit; font: 700 0.85rem/22px var(--font); cursor: pointer; opacity: 0.7; }
.ws-tool:hover { opacity: 1; background: rgba(0, 0, 0, 0.08); }
.ws-row.is-open .ws-tool:hover { background: rgba(255, 255, 255, 0.2); }
.ws-rename { flex: 1 1 auto; min-width: 0; font: inherit; padding: 2px 6px; border: 1px solid var(--accent); border-radius: 5px; background: var(--surface); color: var(--fg); outline: 0; }
.ws-empty { padding: 14px 16px; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.ws-status { margin: 0; padding: 0 12px; font-size: 0.8rem; line-height: 1.4; color: var(--muted); }
.ws-status:not(:empty) { padding: 8px 12px; border-top: 1px solid var(--border); }
.ws-status.is-warn { color: var(--warn-fg); background: var(--warn-bg); }

/* toolbar: back + where the open file is, on the left of the workspace's actions */
.ws-filebar { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 220px; font-size: 0.88rem; color: var(--muted); }
.ws-filebar .mde-btn[hidden] { display: none; }
.ws-crumb { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-crumb-sep { margin: 0 5px; opacity: 0.6; }
.ws-crumb-file { font-weight: 700; color: var(--heading); }

/* the open file: the embedded Markdown editor fills the column; its text, preview and blocks scroll inside */
.ws-edit { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ws-editor { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; border: 0; border-radius: 0; box-shadow: none; }
.ws-editor[hidden] { display: none; }
.ws-editor > .mde-bar { padding: 8px 12px; }
.ws-editor > .mde-panes { flex: 1 1 auto; height: auto; min-height: 0; }
.ws-editor > .mde-blocks { flex: 1 1 auto; min-height: 0; overflow: auto; }
/* the column is narrower than the editor's own page: the insert buttons wrap, undo/redo stay top right */
.ws-editor .mdb-bar { flex-wrap: nowrap; align-items: flex-start; }
.ws-editor .mdb-insert { flex: 1 1 auto; min-width: 0; }
.ws-editor .mdb-hist { flex: 0 0 auto; flex-wrap: nowrap; }
.ws-editor .mde-plain { margin: 0; white-space: pre-wrap; font-family: var(--mono); font-size: 0.88rem; background: none; padding: 0; }
.ws-preview .ws-broken, .ws-editor .mdb-view .ws-broken { color: var(--err-fg); text-decoration: underline dashed; cursor: not-allowed; }

/* an image, or nothing open */
.ws-viewer { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.ws-viewer[hidden] { display: none; }
.ws-viewer-img { max-width: 100%; max-height: 70%; height: auto; object-fit: contain; box-shadow: var(--shadow-sm); background: repeating-conic-gradient(#eef1f6 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.ws-viewer-note { margin: 0; max-width: 32rem; color: var(--muted); font-size: 0.9rem; }

/* dropping files from outside */
.ws-dropzone { position: absolute; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center; padding: 24px; text-align: center; font-weight: 700; font-size: 1.05rem; color: var(--heading); background: rgba(228, 236, 254, 0.72); outline: 2px dashed var(--accent); outline-offset: -10px; border-radius: var(--radius); pointer-events: none; }
.ws.drag > .ws-dropzone { display: flex; }
.ws.drag .ws-tree-pane { position: relative; z-index: 11; }

@media (max-width: 720px) {
  .ws-body { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; min-height: 0; }
  .ws-tree-pane { max-height: 34vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .ws-edit { height: 75vh; }
}
