{% if entry.kind == 'dir' %}
<li class="file-tree-row file-tree-row-dir{% if files_overlay %} files-row{% endif %}"
    {% if files_overlay %}draggable="true" data-target-path="{{ entry.rel }}" data-row-kind="dir"{% endif %}>
  <button type="button"
          class="file-tree-toggle"
          aria-expanded="false"
          data-files-url="{{ files_base_url }}/files?path={{ entry.rel|urlencode }}">
    <span class="chevron" aria-hidden="true">›</span>{{ entry.name }}/
  </button>
  {% if files_overlay %}
  <span class="files-row-actions" aria-label="Folder actions">
    <button type="button" class="files-row-action" data-action="new-file" data-target-path="{{ entry.rel }}" title="New file">+ file</button>
    <button type="button" class="files-row-action" data-action="new-folder" data-target-path="{{ entry.rel }}" title="New folder">+ folder</button>
    <button type="button" class="files-row-action" data-action="zip" data-target-path="{{ entry.rel }}" title="Download as zip">⬇ zip</button>
    <button type="button" class="files-row-action files-row-danger" data-action="delete" data-target-path="{{ entry.rel }}" data-row-kind="dir" data-row-name="{{ entry.name }}" title="Delete folder">✕</button>
  </span>
  {% endif %}
  <div class="file-tree-children" hidden></div>
</li>
{% else %}
{% set has_actions = not entry.broken %}
<li class="file-tree-row file-tree-row-file{% if has_actions %} files-row{% endif %}"
    {% if files_overlay %}draggable="true" data-target-path="{{ entry.rel }}" data-row-kind="file" data-editable="{{ '1' if entry.editable else '0' }}"{% endif %}>
  {% if entry.broken %}
    <span>{{ entry.name }}</span>
    <span class="file-tree-badge file-tree-badge-warn">broken link</span>
  {% else %}
    {% if files_overlay %}
    <button type="button" class="file-tree-name-button" data-action="edit" data-target-path="{{ entry.rel }}" data-editable="{{ '1' if entry.editable else '0' }}" title="Open in editor">{{ entry.name }}</button>
    {% else %}
    <span>{{ entry.name }}</span>
    {% endif %}
    {% if entry.is_symlink %}<span class="file-tree-badge">link</span>{% endif %}
    <span class="muted">{{ entry.size_human }}</span>
  {% endif %}
  {% if has_actions %}
  <span class="files-row-actions" aria-label="File actions">
    <a class="files-row-action" href="{{ files_base_url }}/files/download?path={{ entry.rel|urlencode }}" title="Download">⬇</a>
    {% if files_overlay %}
    <button type="button" class="files-row-action files-row-danger" data-action="delete" data-target-path="{{ entry.rel }}" data-row-kind="file" data-row-name="{{ entry.name }}" title="Delete">✕</button>
    {% endif %}
  </span>
  {% endif %}
</li>
{% endif %}
