:root {
    --linen: #f4f0e3;
    --linen-dark: #e8e2d0;
    --sage: #9aa583;
    --sage-dark: #7d8c6e;
    --forest: #3d5b47;
    --forest-dark: #2c3e33;
    --stone: #6b7d8a;
    --border: #e4e1d7;
    --surface: #ffffff;
    --surface-alt: #faf8f1;
    --text: #24302a;
    --muted: #6b7269;
    --danger: #b04a3c;
}

html, body {
    margin: 0; padding: 0;
    height: 100vh;
    font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--linen);
    color: var(--text);
    overflow: hidden;
}

.commune-header { flex-shrink: 0; }

.wm-layout {
    display: grid;
    grid-template-columns: 290px 1fr 6px 1fr;
    height: calc(100vh - 60px);
    gap: 0;
    position: relative;
}

.wm-splitter {
    cursor: col-resize;
    background: var(--border);
    position: relative;
    user-select: none;
    transition: background .15s;
    z-index: 2;
}
.wm-splitter::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: -4px; right: -4px;
}
.wm-splitter:hover,
.wm-splitter.wm-splitter-dragging {
    background: var(--primary, #0d6efd);
}
body.wm-resizing,
body.wm-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
}
body.wm-resizing iframe {
    pointer-events: none;
}

.wm-pane {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--surface);
    min-width: 0;
    overflow: hidden;
}
.wm-pane-right { border-right: none; }

.wm-pane-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    font-size: .9rem;
}
.wm-spacer { flex: 1; }

/* Left pane */
.wm-drop {
    margin: .75rem;
    padding: 1rem .75rem;
    border: 2px dashed #cfd0c2;
    border-radius: 10px;
    text-align: center;
    font-size: .85rem;
    color: var(--muted);
    cursor: pointer;
    transition: all .15s ease;
}
.wm-drop:hover,
.wm-drop.wm-drop-active {
    border-color: var(--sage);
    background: rgba(154, 165, 131, .09);
    color: var(--text);
}
.wm-drop i { font-size: 1.3rem; display: block; margin-bottom: .25rem; }
.wm-drop-sub { font-size: .75rem; margin-top: .25rem; color: var(--muted); }
.wm-drop-sub a { color: var(--forest); text-decoration: none; }
.wm-drop-sub a:hover { text-decoration: underline; }

.wm-note-input {
    margin: 0 .75rem .5rem;
    width: calc(100% - 1.5rem);
    font-size: .78rem;
}
.wm-note-inline {
    margin: 0;
    max-width: 14rem;
    flex: 0 1 14rem;
    min-width: 0;
}

.wm-progress { margin: 0 .75rem .5rem; }
.wm-progress-bar {
    height: 4px;
    background: linear-gradient(90deg, var(--sage) 0%, var(--sage-dark) 100%);
    border-radius: 2px;
    width: 0%;
    transition: width .2s ease;
}
.wm-progress-label { font-size: .75rem; color: var(--muted); margin-top: .25rem; }

.wm-tree-toolbar {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem .75rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
}
.wm-target {
    font-size: .72rem;
    color: var(--muted);
    font-family: 'SF Mono', Menlo, monospace;
    margin-left: auto;
    max-width: 170px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wm-tree-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.wm-tree {
    flex: 1;
    overflow: auto;
    padding: .4rem .25rem;
    font-size: .85rem;
}

.wm-node {
    display: flex;
    align-items: center;
    gap: .3rem;
    padding: .15rem .4rem;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
}
.wm-node:hover { background: rgba(154, 165, 131, .12); }
.wm-node.wm-selected { background: rgba(61, 91, 71, .15); color: var(--forest-dark); font-weight: 600; }
.wm-node.wm-target-dir {
    outline: 2px solid var(--sage);
    outline-offset: -2px;
    background: rgba(154, 165, 131, .18);
}
.wm-node.wm-target-dir .wm-node-name::after {
    content: ' ← uploads here';
    color: var(--forest);
    font-weight: 600;
    font-size: .72rem;
    margin-left: .4rem;
    opacity: .85;
}
.wm-node-root {
    position: sticky;
    top: 0;
    background: var(--surface-alt);
    z-index: 2;
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}
.wm-node-root i.bi { color: var(--forest); }

/* Drag-and-drop move feedback */
.wm-node[draggable="true"] { cursor: grab; }
.wm-node[draggable="true"]:active { cursor: grabbing; }
.wm-node.wm-drop-over {
    background: rgba(61, 91, 71, .22);
    outline: 2px dashed var(--forest);
    outline-offset: -2px;
}
.wm-node.wm-drop-invalid {
    background: rgba(176, 74, 60, .14);
    outline: 2px dashed var(--danger);
    outline-offset: -2px;
    cursor: not-allowed;
}
.wm-node i.bi { color: var(--muted); font-size: .9rem; flex-shrink: 0; }
.wm-node-name { overflow: hidden; text-overflow: ellipsis; }
.wm-children { padding-left: 1rem; border-left: 1px dotted #e4e1d7; margin-left: .5rem; }
.wm-node-actions {
    display: none;
    margin-left: auto;
    gap: .2rem;
}
.wm-node:hover .wm-node-actions { display: flex; }
.wm-node-actions button {
    background: none;
    border: none;
    padding: 0 .2rem;
    font-size: .75rem;
    color: var(--muted);
    cursor: pointer;
}
.wm-node-actions button:hover { color: var(--danger); }

/* Center pane */
.wm-editor-toolbar { gap: .5rem; }
.wm-current-path {
    font-family: 'SF Mono', Menlo, monospace;
    font-size: .82rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 55%;
}
.wm-current-path.wm-dirty::after {
    content: '•';
    color: var(--desert, #c8856a);
    margin-left: .4rem;
    font-size: 1.4rem;
    line-height: 0;
    vertical-align: middle;
}
.wm-editor-host { flex: 1; min-height: 0; }
.monaco-editor .wm-dirty-gutter {
    margin-left: 3px;
    width: 3px !important;
}
.monaco-editor .wm-dirty-added { background: rgba(40, 167, 69, 0.85); }
.monaco-editor .wm-dirty-modified { background: rgba(13, 110, 253, 0.85); }
.monaco-editor .wm-dirty-deleted {
    background: transparent;
    border-top: 3px solid rgba(220, 53, 69, 0.85);
    height: 0 !important;
}
.wm-image-host {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #222;
    padding: 1rem;
    overflow: auto;
}
.wm-image-host img { max-width: 100%; max-height: 100%; box-shadow: 0 4px 24px rgba(0,0,0,.4); }
.wm-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    text-align: center;
    padding: 2rem;
}
.wm-empty-state i { font-size: 3rem; margin-bottom: .5rem; opacity: .4; }

/* Right pane */
.wm-preview {
    flex: 1;
    width: 100%;
    border: 0;
    background: #fff;
}

/* History drawer */
.wm-drawer {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 380px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 16px rgba(0,0,0,.07);
    display: flex;
    flex-direction: column;
    z-index: 20;
}
.wm-drawer-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
}
.wm-drawer-body { flex: 1; overflow: auto; padding: .25rem 0; }
.wm-commit {
    padding: .6rem .85rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: .15rem;
    font-size: .85rem;
}
.wm-commit-head { display: flex; align-items: center; gap: .5rem; }
.wm-commit-author { font-weight: 600; }
.wm-commit-date { color: var(--muted); font-size: .78rem; }
.wm-commit-msg { color: var(--text); }
.wm-commit-body {
    color: var(--muted);
    font-size: .78rem;
    font-style: italic;
    white-space: pre-wrap;
    word-break: break-word;
    margin-top: .1rem;
    padding-left: .5rem;
    border-left: 2px solid var(--border);
}
.wm-commit-meta { color: var(--muted); font-size: .75rem; }
.wm-commit-changes > summary { cursor: pointer; list-style: none; display: inline-block; }
.wm-commit-changes > summary::-webkit-details-marker { display: none; }
.wm-commit-changes > summary::before { content: "▸ "; display: inline-block; transition: transform .15s ease; }
.wm-commit-changes[open] > summary::before { content: "▾ "; }
.wm-commit-changes > summary:hover { color: var(--text); }
.wm-change-list {
    list-style: none;
    margin: .35rem 0 .1rem;
    padding: .25rem .25rem .25rem .75rem;
    max-height: 14rem;
    overflow: auto;
    border-left: 2px solid var(--border);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .72rem;
}
.wm-change-item { display: flex; gap: .4rem; align-items: baseline; padding: .1rem 0; color: var(--text); }
.wm-change-path { word-break: break-all; }
.wm-change-badge {
    flex: 0 0 auto;
    min-width: 3.25rem;
    text-align: center;
    text-transform: uppercase;
    font-size: .62rem;
    letter-spacing: .03em;
    padding: .05rem .35rem;
    border-radius: 3px;
    background: var(--surface-alt);
    color: var(--muted);
    font-family: system-ui, sans-serif;
}
.wm-change-added { background: #1f6f43; color: #e8fbef; }
.wm-change-modified { background: #1c5fa8; color: #e7f1ff; }
.wm-change-deleted { background: #8a2a2a; color: #fde8e8; }
.wm-change-renamed { background: #6b5a18; color: #fff5d5; }
.wm-commit-actions { margin-top: .25rem; display: flex; gap: .35rem; flex-wrap: wrap; }
.wm-commit-actions .btn { font-size: .75rem; }

/* Toasts */
.wm-toasts {
    position: fixed;
    bottom: 1.25rem; right: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    z-index: 1080;
}
.wm-toast {
    background: var(--forest-dark);
    color: var(--linen);
    padding: .65rem 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    font-size: .88rem;
    max-width: 380px;
    animation: wm-toast-in .18s ease-out;
}
.wm-toast.wm-toast-error { background: var(--danger); }
@keyframes wm-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
