/* Mobile folder browsing uses the workspace palette and the existing local folder metadata. */
.notes-workspace-folder-explorer-trigger,
.notes-workspace-all-notes-trigger {
  display: none;
}

.funify-notes-page .notes-folder-explorer {
  position: fixed;
  inset: 0 auto 0 0;
  box-sizing: border-box;
  width: min(85vw, 340px);
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-right: 1px solid var(--color-border);
  border-radius: 0;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 12px 0 36px rgb(0 0 0 / 15%);
  font: inherit;
}

.funify-notes-page .notes-folder-explorer[open] {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  animation: notes-folder-explorer-enter 180ms ease-out;
}

.notes-folder-explorer::backdrop {
  background: rgb(15 23 42 / 40%);
}

body[data-folder-explorer-open='true'] {
  overflow: hidden;
}

html:has(body[data-folder-explorer-open='true']) {
  overflow: hidden;
}

.notes-folder-explorer svg {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.notes-folder-explorer button {
  box-sizing: border-box;
  min-height: 44px;
  padding: 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.notes-folder-explorer button:disabled {
  opacity: 0.45;
  cursor: default;
}

.notes-folder-explorer button:not(:disabled):hover {
  background: var(--notes-workspace-soft);
}

.notes-folder-explorer :is(button, input):focus-visible,
.notes-workspace-all-notes-trigger:focus-visible,
.notes-workspace-folder-explorer-trigger:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.notes-folder-explorer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--color-border);
}

.notes-folder-explorer-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.notes-folder-explorer-action {
  display: inline-flex;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  width: 44px;
}

.notes-folder-explorer-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 12px 8px max(12px, env(safe-area-inset-left));
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-muted);
}

.notes-folder-explorer-search input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 14px;
}

.notes-folder-explorer-scroll {
  min-height: 0;
  padding: 0 8px 12px max(8px, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.notes-folder-explorer-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 4px 8px;
  color: var(--color-muted);
}

.notes-folder-explorer-section h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.notes-folder-explorer-row {
  display: flex;
  align-items: center;
  padding-left: calc(var(--folder-depth) * 12px);
  border-radius: 7px;
}

.notes-folder-explorer-row[data-active='true'],
.notes-folder-explorer-shortcut[aria-current='page'] {
  background: var(--notes-workspace-soft);
  color: var(--color-primary);
}

.notes-folder-explorer-toggle,
.notes-folder-explorer-spacer {
  display: inline-flex;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  width: 44px;
}

.notes-folder-explorer-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 150ms ease;
}

.notes-folder-explorer-toggle[aria-expanded='true'] svg {
  transform: rotate(90deg);
}

.notes-folder-explorer-folder,
.notes-folder-explorer-shortcut {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.notes-folder-explorer-folder {
  flex: 1;
}

.notes-folder-explorer-folder span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-folder-explorer-shortcut {
  width: 100%;
}

.notes-folder-explorer-shortcuts {
  padding: 8px 12px max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border-top: 1px solid var(--color-border);
}

.notes-folder-explorer-empty {
  margin: 16px 8px;
  color: var(--color-muted);
  font-size: 13px;
}

@keyframes notes-folder-explorer-enter {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(0);
  }
}

@media screen and (max-width: 767px) {
  .notes-workspace-heading-group {
    position: relative;
    flex: 0 0 100%;
    box-sizing: border-box;
    min-width: 0;
    min-height: 32px;
    padding-right: 84px;
  }

  .notes-workspace-heading-group h2 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .notes-workspace-heading-group .notes-workspace-category-select {
    flex-shrink: 1;
  }

  :is(.notes-workspace-folder-explorer-trigger, .notes-workspace-all-notes-trigger) {
    position: absolute;
    top: 50%;
    right: 0;
    display: inline-flex;
    flex: 0 0 32px;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 6px;
    transform: translateY(-50%);
    border: 0;
    border-radius: 10px;
    background: var(--notes-workspace-soft);
    color: var(--color-muted);
    cursor: pointer;
  }

  :is(.notes-workspace-folder-explorer-trigger, .notes-workspace-all-notes-trigger) svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .notes-workspace-all-notes-trigger {
    right: 40px;
  }

  .notes-workspace-all-notes-trigger:hover,
  .notes-workspace-all-notes-trigger:active,
  .notes-workspace-folder-explorer-trigger:hover,
  .notes-workspace-folder-explorer-trigger:active,
  .notes-workspace-folder-explorer-trigger[aria-expanded='true'] {
    background: var(--notes-workspace-soft);
    color: var(--color-primary);
  }

  .notes-workspace-breadcrumbs {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
  }

  .notes-workspace-breadcrumbs button {
    display: inline-block;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .funify-notes-page .notes-folder-explorer[open] {
    animation: none;
  }

  .notes-folder-explorer-toggle svg {
    transition: none;
  }
}
