:root {
  --brush-library-bg: #2f3032;
  --brush-library-rail: #292a2c;
  --brush-library-card: #424345;
  --brush-library-card-hover: #4a4b4e;
  --brush-library-text: #e7e7e7;
  --brush-library-muted: #9c9da1;
  --brush-library-accent: #22a9df;
}

.brush-palette {
  position: absolute;
  z-index: 80;
  inset: 0 auto 0 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 0;
  width: min(590px, 100vw);
  height: 100vh;
  max-height: none;
  padding: 0;
  overflow: hidden;
  color: var(--brush-library-text);
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0 14px 14px 0;
  background: var(--brush-library-bg);
  box-shadow: 18px 0 56px rgba(0, 0, 0, 0.44);
  backdrop-filter: none;
}

.brush-palette:focus {
  outline: none;
}

.has-brush-library-open .topbar {
  opacity: 0;
  visibility: hidden;
}

.brush-palette[hidden] {
  display: none !important;
}

.brush-library__header {
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  padding: max(12px, env(safe-area-inset-top)) 17px 10px 26px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
}

.brush-library__header h2 {
  margin: 0;
  color: var(--brush-library-text);
  font-size: 1.34rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.brush-library__header-actions,
.brush-library__footer-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.brush-library__icon-button,
.brush-library__footer-actions button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: #dedfe1;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
}

.brush-library__icon-button:hover,
.brush-library__icon-button[aria-expanded="true"],
.brush-library__footer-actions button:hover,
.brush-library__footer-actions button[aria-pressed="true"] {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
}

.brush-library__icon-button:focus-visible,
.brush-library__footer-actions button:focus-visible,
.brush-library__load-button:focus-visible,
.brush-library__group-button:focus-visible {
  outline: 2px solid var(--brush-library-accent);
  outline-offset: -2px;
}

.brush-library__icon-button svg,
.brush-library__search > svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.brush-library__close {
  font-size: 1.7rem;
  font-weight: 300;
  line-height: 1;
}

.brush-library__search {
  grid-row: 2;
  display: none;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 7px 16px 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: #2b2c2e;
}

.brush-palette.is-search-open .brush-library__search {
  display: grid;
}

.brush-library__search > svg {
  width: 21px;
  height: 21px;
  color: var(--brush-library-muted);
}

.brush-library__search label {
  min-width: 0;
}

.brush-catalog .brush-library__search input[type="search"] {
  width: 100%;
  height: 36px;
  padding: 0 3px;
  color: #f5f5f5;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  font-size: 0.86rem;
}

.brush-library__search output {
  color: var(--brush-library-muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.brush-library__body {
  grid-row: 3;
  display: grid;
  grid-template-columns: clamp(148px, 31%, 184px) minmax(0, 1fr);
  min-height: 0;
}

.brush-library__groups {
  min-width: 0;
  padding: 13px 0 16px;
  overflow: auto;
  overscroll-behavior: contain;
  border-right: 1px solid rgba(255, 255, 255, 0.035);
  background: var(--brush-library-rail);
  scrollbar-width: thin;
}

.brush-library__groups-placeholder {
  display: block;
  padding: 18px 24px;
  color: #737477;
  font-size: 0.86rem;
}

.brush-library__group-button {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 9px 17px 9px 26px;
  overflow: hidden;
  color: #a9aaad;
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.brush-library__group-button::before {
  position: absolute;
  inset: 11px auto 11px 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
  content: "";
}

.brush-library__group-button:hover {
  color: #d7d7d8;
  background: rgba(255, 255, 255, 0.035);
}

.brush-library__group-button[aria-pressed="true"] {
  color: var(--brush-library-accent);
  background: rgba(34, 169, 223, 0.045);
}

.brush-library__group-button[aria-pressed="true"]::before {
  background: var(--brush-library-accent);
}

.brush-library__group-name {
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 560;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brush-library__group-count {
  color: #737579;
  font-size: 0.63rem;
  font-variant-numeric: tabular-nums;
}

.brush-library__content {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  background: #303133;
}

.brush-library__status {
  min-height: 27px;
  padding: 7px 13px 3px;
  overflow: hidden;
  color: #8f9094;
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brush-catalog[data-state="loading"] .brush-library__status {
  color: #d3b574;
}

.brush-catalog[data-state="error"] .brush-library__status {
  color: #ff8f8f;
}

.brush-palette .brush-catalog__list {
  display: none;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 5px;
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 0;
  padding: 3px 10px 14px 8px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
}

.brush-palette[data-library-state="ready"] .brush-catalog__list {
  display: grid;
}

.brush-card-shell {
  position: relative;
  min-width: 0;
  height: 104px;
}

.brush-card-shell .brush-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 2px;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 9px 34px 7px 11px;
  overflow: hidden;
  color: var(--brush-library-text);
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--brush-library-card);
}

.brush-card-shell .brush-card:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: var(--brush-library-card-hover);
}

.brush-card-shell .brush-card[aria-pressed="true"] {
  border-color: rgba(34, 169, 223, 0.78);
  background: #3d464a;
  box-shadow: inset 3px 0 0 var(--brush-library-accent);
}

.brush-card-shell .brush-card:disabled {
  cursor: wait;
  opacity: 0.58;
}

.brush-card-shell .brush-card__copy {
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  grid-row: 1;
}

.brush-palette .brush-card__name {
  color: #e3e3e4;
  font-size: 0.78rem;
  font-weight: 530;
}

.brush-palette .brush-card__group {
  max-width: 47%;
  color: #98999c;
  font-size: 0.63rem;
  text-align: right;
}

.brush-card-shell .brush-card__preview {
  grid-row: 2;
  width: 100%;
  height: 67px;
  border: 0;
  border-radius: 0;
  background: transparent;
  filter: grayscale(1) invert(1) contrast(1.2);
  mix-blend-mode: screen;
  object-fit: cover;
  object-position: center;
  opacity: 0.72;
}

.brush-card__favorite {
  top: 7px;
  right: 7px;
  width: 26px;
  height: 26px;
  color: #aaa;
  background: transparent;
}

.brush-card__favorite:hover,
.brush-card__favorite[aria-pressed="true"] {
  color: #ffd66f;
  background: rgba(0, 0, 0, 0.19);
}

.brush-library__loader {
  position: absolute;
  inset: 27px 0 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 9px;
  padding: 26px;
  color: #e6e6e6;
  text-align: center;
}

.brush-palette[data-library-state="ready"] .brush-library__loader {
  display: none;
}

.brush-library__loader-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  color: var(--brush-library-accent);
  border: 1px solid rgba(34, 169, 223, 0.35);
  border-radius: 50%;
  background: rgba(34, 169, 223, 0.08);
  font-size: 1.35rem;
}

.brush-palette[data-library-state="loading"] .brush-library__loader-icon {
  animation: brush-library-pulse 1.1s ease-in-out infinite;
}

.brush-library__loader strong {
  font-size: 0.94rem;
  font-weight: 610;
}

.brush-library__loader p {
  max-width: 260px;
  margin: 0;
  color: var(--brush-library-muted);
  font-size: 0.72rem;
  line-height: 1.55;
}

.brush-library__load-button {
  min-height: 40px;
  margin-top: 5px;
  padding: 8px 17px;
  color: #fff;
  border: 0;
  border-radius: 9px;
  background: #168bbd;
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 650;
}

.brush-library__load-button:hover {
  background: #1a9fd7;
}

.brush-library__load-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.brush-library__footer {
  grid-row: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 57px;
  padding: 7px 14px max(7px, env(safe-area-inset-bottom)) 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.065);
  background: #2b2c2e;
}

.brush-library__license {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #aaa;
  font-size: 0.73rem;
  text-decoration: none;
}

.brush-library__license:hover {
  color: #ddd;
}

.brush-library__footer-actions button {
  width: 38px;
  height: 38px;
  color: #d4d4d5;
  font-size: 1.25rem;
}

.brush-catalog__empty {
  margin: 36px 0;
  color: #97989b;
}

@keyframes brush-library-pulse {
  50% {
    opacity: 0.55;
    transform: scale(0.94);
  }
}

@media (max-width: 700px) {
  .brush-palette {
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  .brush-library__body {
    grid-template-columns: clamp(128px, 34vw, 164px) minmax(0, 1fr);
  }

  .brush-library__header {
    min-height: 62px;
    padding-left: 20px;
  }

  .brush-library__header h2 {
    font-size: 1.18rem;
  }

  .brush-library__group-button {
    min-height: 52px;
    padding-right: 12px;
    padding-left: 20px;
  }

  .brush-card-shell {
    height: 99px;
  }
}

@media (max-width: 390px) {
  .brush-library__group-button {
    padding-left: 15px;
  }

  .brush-library__group-name {
    font-size: 0.78rem;
  }

  .brush-library__group-count {
    display: none;
  }

  .brush-library__header-actions {
    gap: 0;
  }

  .brush-library__icon-button {
    width: 36px;
    height: 38px;
  }

  .brush-library__footer {
    padding-left: 14px;
  }

  .brush-library__license span:last-child {
    display: none;
  }
}
