section.bucket {
  min-height: 0;
}

section.bucket > .bucket-detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 10px;
}

section.bucket > .bucket-detail-toolbar > .bucket-detail-toolbar-spacer {
  flex: 1 1 auto;
}

section.bucket > .summary {
  margin-top: 0;
  margin-bottom: 12px;
}

section.bucket > .bucket-detail-visual {
  display: none;
  min-height: 0;
}

section.bucket > .bucket-detail-visual > .bucket-detail-visual-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 0;
  height: 100%;
}

section.bucket.is-visual-mode.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

section.bucket.is-visual-mode > .bucket-detail-visual {
  display: flex;
  flex: 1 1 auto;
  height: 100%;
}

section.bucket.is-visual-mode > .bucket-detail-visual > .bucket-detail-visual-panel {
  flex: 1 1 auto;
}

section.bucket > .bucket-detail-visual .bucket-treemap {
  position: relative;
  min-height: clamp(320px, 52vh, 680px);
  height: 100%;
  min-width: 0;
}

section.bucket > .bucket-detail-visual .bucket-treemap-plot {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: inherit;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--panel) 92%, #d8e8ff 8%), transparent 56%),
    linear-gradient(180deg, color-mix(in srgb, var(--panel) 88%, #16212b 12%), color-mix(in srgb, var(--panel) 94%, black 6%));
  border: 1px solid color-mix(in srgb, var(--border) 86%, transparent);
}

section.bucket > .bucket-detail-visual .bucket-treemap-tile {
  position: absolute;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--tile-color, var(--accent));
  color: var(--tile-text-color, var(--text));
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--panel) 70%, transparent),
    inset 0 1px 0 color-mix(in srgb, #ffffff 24%, transparent);
  overflow: hidden;
  transition:
    transform 180ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 180ms ease,
    filter 180ms ease,
    opacity 180ms ease;
}

section.bucket > .bucket-detail-visual .bucket-treemap-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, color-mix(in srgb, #ffffff 20%, transparent), transparent 40%),
    linear-gradient(180deg, color-mix(in srgb, black 10%, transparent), transparent 48%);
  opacity: 0.38;
  pointer-events: none;
}

section.bucket > .bucket-detail-visual .bucket-treemap-tile:hover,
section.bucket > .bucket-detail-visual .bucket-treemap-tile:focus-visible {
  background: var(--tile-color, var(--accent));
  transform: scale(0.985);
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--panel) 54%, transparent),
    inset 0 1px 0 color-mix(in srgb, #ffffff 34%, transparent),
    0 10px 24px color-mix(in srgb, var(--shadow) 20%, transparent);
}

section.bucket > .bucket-detail-visual .bucket-treemap-tile.is-drillable {
  cursor: zoom-in;
}

section.bucket > .bucket-detail-visual .bucket-treemap-tile.is-revealed {
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--panel) 42%, transparent),
    inset 0 1px 0 color-mix(in srgb, #ffffff 36%, transparent),
    0 14px 30px color-mix(in srgb, var(--shadow) 26%, transparent);
  filter: saturate(1.05) brightness(1.02);
}

section.bucket > .bucket-detail-visual .bucket-treemap-tile-content {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 10px;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 160ms ease, transform 180ms ease;
  pointer-events: none;
  text-align: center;
}

section.bucket > .bucket-detail-visual .bucket-treemap-tile.is-revealed .bucket-treemap-tile-content {
  opacity: 1;
  transform: scale(1);
}

section.bucket > .bucket-detail-visual .bucket-treemap-tile-icon {
  font-size: clamp(1rem, 2vw, 1.7rem);
  line-height: 1;
}

section.bucket > .bucket-detail-visual .bucket-treemap-tile-amount {
  font-size: clamp(0.72rem, 1.2vw, 1rem);
  font-weight: 700;
  line-height: 1.15;
}

section.bucket > .bucket-detail-visual .bucket-detail-visual-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

section.bucket > .bucket-detail-visual .bucket-detail-back {
  min-width: 92px;
}

section.bucket > .bucket-detail-visual .bucket-detail-level {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bucket-detail-visual-panel.is-entering .bucket-treemap-tile {
  animation: bucket-chart-bucket-in 620ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--enter-index, 0) * 26ms);
}

section.bucket > .categories {
  padding-bottom: 8px;
}

.bucket .category-nested {
  margin-top: 0;
  margin-bottom: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.bucket .category-nested:hover {
  border-color: transparent;
}

.bucket .category-nested > .category-header {
  padding: 10px 14px;
  background: color-mix(in srgb, var(--panel) 72%, var(--btn-bg) 28%);
  border-top: 1px solid var(--border);
}

.bucket .category-nested:hover > .category-header {
  background: color-mix(in srgb, var(--panel) 64%, var(--btn-bg) 36%);
}

.bucket .category-nested > .category-body {
  margin-inline-start: 14px;
}

@media (max-width: 640px) {
  section.bucket > .bucket-detail-visual .bucket-treemap {
    min-height: clamp(280px, 48vh, 560px);
  }

  section.bucket > .bucket-detail-visual .bucket-detail-visual-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  section.bucket > .bucket-detail-visual .bucket-detail-level {
    text-align: left;
    white-space: normal;
  }
}
