.profile-collection-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 16px;
  min-height: 44px;
}

.profile-collection-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border, #eadce4);
  border-radius: 12px;
  background: var(--surface-soft, #fff8fb);
}

.profile-collection-tabs button {
  min-width: 72px;
  min-height: 36px;
  padding: 7px 16px;
  border: 0;
  border-radius: 9px;
  color: var(--muted, #756a74);
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.profile-collection-tabs button.is-active {
  color: var(--ink, #403342);
  background: var(--surface, #fff);
  box-shadow: 0 2px 8px rgba(92, 53, 72, .09);
}

.profile-category-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -2px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border, #eadce4);
  border-radius: 12px;
  background: var(--surface-soft, #fff9fb);
}

.profile-category-context-main,
.profile-category-context-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-category-context h3,
.profile-category-context p { margin: 0; }
.profile-category-context p { margin-top: 2px; color: var(--muted, #766b75); font-size: 13px; }

.profile-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.profile-folder-card {
  min-width: 0;
  border: 1px solid var(--border, #eadce4);
  border-radius: 14px;
  background: var(--surface, #fff);
  box-shadow: 0 5px 18px rgba(88, 50, 68, .06);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.profile-folder-card:hover {
  border-color: var(--accent-soft, #e4a9bc);
  box-shadow: 0 8px 22px rgba(88, 50, 68, .1);
  transform: translateY(-1px);
}

.profile-folder-open {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 86px;
  padding: 16px;
  border: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.profile-folder-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  color: var(--accent, #bd5578);
  background: var(--accent-faint, #fff0f5);
}

.profile-folder-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.profile-folder-copy { min-width: 0; }
.profile-folder-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-folder-copy small { display: block; margin-top: 5px; color: var(--muted, #766b75); }
.profile-folder-chevron { color: var(--muted, #938690); font-size: 24px; }

.profile-category-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin-top: 7px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--accent, #a94667);
  background: var(--accent-faint, #fff0f5);
  font-size: 12px;
  font-weight: 700;
}

.profile-category-panel { width: min(560px, calc(100vw - 32px)); }
.profile-category-options { display: grid; gap: 8px; margin: 16px 0; max-height: min(360px, 50vh); overflow-y: auto; }
.profile-category-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border, #eadce4);
  border-radius: 10px;
  background: var(--surface, #fff);
  cursor: pointer;
}
.profile-category-choice:has(input:checked) { border-color: var(--accent, #bd5578); background: var(--accent-faint, #fff4f7); }
.profile-category-choice input { flex: 0 0 auto; }
.profile-category-choice span { min-width: 0; overflow-wrap: anywhere; }
.profile-category-choice small { margin-left: auto; color: var(--muted, #766b75); white-space: nowrap; }

.profile-collection-tabs button:focus-visible,
.profile-folder-open:focus-visible,
.profile-category-choice:focus-within {
  outline: 3px solid rgba(194, 82, 120, .3);
  outline-offset: 2px;
}

.profile-card-menu-panel .profile-category-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 22px;
  min-height: 22px;
}

.profile-category-menu-trigger > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Keep dynamically injected profile menu actions aligned with native actions. */
#view-my .profile-card-menu-panel button {
  height: 22px;
  min-height: 22px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
}

#view-my .profile-card-menu-panel > button:not(.is-danger):not(:disabled) {
  color: var(--ink, #403343);
}

#view-my .profile-category-menu-trigger > span:first-child {
  color: inherit;
  font: inherit;
}


.profile-category-choice svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.profile-category-choice.is-add {
  color: var(--accent, #a94667);
  border-style: dashed;
}

.profile-category-options[aria-invalid="true"] {
  outline: 3px solid rgba(194, 82, 120, .24);
  outline-offset: 3px;
}

@media (max-width: 620px) {
  .profile-collection-toolbar,
  .profile-category-context { align-items: stretch; flex-direction: column; }
  .profile-collection-tabs { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .profile-collection-tabs button { min-height: 44px; }
  .profile-category-context-main { align-items: flex-start; }
  .profile-category-context-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .profile-category-context-actions .button, .profile-category-context-main .button { min-height: 44px; }
  .profile-folder-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .profile-collection-tabs button,
  .profile-folder-card { transition: none; }
  .profile-folder-card:hover { transform: none; }
}

/* Profile category previews follow the missing-bead card layout. */
#view-my .profile-content-panel {
  grid-template-rows: auto auto minmax(0, 1fr);
}

#view-my .my-pattern-list {
  align-content: start;
  grid-auto-rows: max-content;
}

#view-my .my-pattern-list > .profile-folder-grid {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  align-self: start;
}

#view-my .profile-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  grid-auto-flow: row;
  grid-auto-rows: 1fr;
  align-items: stretch;
  gap: 12px;
}

#view-my .profile-folder-card {
  width: 100%;
  min-width: 0;
  min-height: 142px;
  height: 100%;
  border-radius: 12px;
  box-shadow: none;
}

#view-my .profile-folder-open {
  width: 100%;
  min-width: 0;
  min-height: 142px;
  height: 100%;
  padding: 14px 16px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

#view-my .profile-folder-copy {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 6px;
}

#view-my .profile-folder-copy strong {
  display: block;
  margin: 0;
  overflow: hidden;
  color: var(--ink, #403342);
  font-size: 17px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#view-my .profile-folder-meta {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 8px;
  color: var(--muted, #766b75);
  font-size: 12px;
  line-height: 1.45;
}

#view-my .profile-folder-meta span + span::before {
  content: "·";
  margin-right: 8px;
  color: rgba(118, 107, 117, .72);
}

#view-my .profile-folder-preview {
  min-width: 0;
  min-height: 42px;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
}

#view-my .profile-folder-preview-item {
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid rgba(77, 59, 73, .16);
  border-radius: 6px;
  background: #fffaf7;
}

#view-my .profile-folder-preview-item > img,
#view-my .profile-folder-preview-item > svg,
#view-my .profile-folder-preview-item .pattern-thumb-svg,
#view-my .profile-folder-preview-item .community-cover-pattern,
#view-my .profile-folder-preview-item .community-cover-pattern > svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#view-my .profile-folder-preview-item .community-cover-count {
  display: none;
}

#view-my .profile-folder-preview-item .community-cover-empty {
  padding: 3px;
  color: var(--muted, #766b75);
  font-size: 9px;
  line-height: 1.2;
  text-align: center;
}

#view-my .profile-folder-preview-more {
  flex: 0 0 28px;
  width: 28px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(244, 237, 241, .82);
  color: #766b75;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

#view-my .profile-folder-preview-empty {
  color: var(--muted, #766b75);
  font-size: 12px;
  line-height: 40px;
}

#view-my .profile-folder-chevron {
  align-self: center;
  color: var(--muted, #938690);
  font-size: 24px;
}

@media (width < 620px) {
  #view-my .profile-folder-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #view-my .profile-folder-open {
    padding: 14px;
  }

  #view-my .profile-folder-preview-item {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
  }
}