/* ── Tags settings (aligned with categories) ───────────────── */
#view-tags {
  position: relative;
}

#view-tags .tag-settings-body {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  gap: 0;
}

.tag-settings-toolbar {
  flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.tag-settings-filter-row {
  padding: 12px 16px 10px;
}

.tag-settings-toolbar.is-search-open .tag-settings-filter-row {
  padding-bottom: 6px;
}

.tag-settings-toolbar .cat-create-type-pin {
  margin: 0;
}

.tag-settings-toolbar.is-search-open .tx-search-line {
  max-height: 52px;
  opacity: 1;
  padding-bottom: 10px;
}

#view-tags .tag-search-fab {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
}

.tag-settings-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Collapsible category groups (like tx-day-group) ───────── */
.tag-cat-group {
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  outline: 1px solid var(--border);
  box-shadow: none;
  touch-action: pan-y;
  transition:
    box-shadow 0.45s cubic-bezier(0.33, 1, 0.68, 1),
    background 0.3s ease,
    outline-color 0.3s ease,
    margin 0.35s cubic-bezier(0.33, 1, 0.68, 1),
    opacity 0.38s cubic-bezier(0.33, 1, 0.68, 1),
    filter 0.38s cubic-bezier(0.33, 1, 0.68, 1);
}

.tag-settings-scroll:has(.tag-cat-group.is-open) .tag-cat-group:not(.is-open) {
  opacity: 0.46;
  filter: saturate(0.62) brightness(0.95);
}

@media (hover: hover) {
  .tag-settings-scroll:has(.tag-cat-group.is-open) .tag-cat-group:not(.is-open):hover {
    opacity: 0.58;
    filter: saturate(0.74) brightness(0.98);
  }
}

.tag-settings-scroll:has(.tag-cat-group.is-open) .tag-cat-group:not(.is-open):active {
  opacity: 0.52;
  filter: saturate(0.68) brightness(0.96);
}

.tag-cat-group.is-open {
  position: relative;
  z-index: 2;
  overflow: visible;
  background: var(--surface);
  outline: none;
  border: 1px solid var(--overlay-border);
  box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--overlay-border);
}

.tag-cat-group:nth-child(even) {
  background: var(--surface-2);
  outline-color: var(--border);
}

.tag-cat-group:nth-child(even).is-open {
  background: var(--surface);
  border-color: var(--overlay-border);
}

.tag-cat-head {
  display: flex;
  align-items: stretch;
  min-width: 0;
}

.tag-cat-toggle {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 14px 28px minmax(0, 1fr);
  gap: 0 10px;
  align-items: center;
  padding: 12px 10px 12px 14px;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  touch-action: pan-y;
  transition: filter 0.15s ease, border-color 0.4s cubic-bezier(0.33, 1, 0.68, 1);
}

.tag-cat-group.is-open .tag-cat-toggle {
  border-bottom-color: var(--border);
  border-radius: 10px 10px 0 0;
  transition-delay: 0.05s;
}

.tag-cat-toggle:active {
  filter: brightness(0.98);
}

.tag-cat-add {
  flex-shrink: 0;
  width: 44px;
  border: none;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 22px;
  line-height: 1;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.4s cubic-bezier(0.33, 1, 0.68, 1);
}

.tag-cat-group.is-open .tag-cat-add {
  border-bottom-color: var(--border);
}

.tag-cat-add:active {
  background: var(--fill-pressed);
  color: var(--accent);
}

.tag-cat-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-3);
  opacity: 0.7;
  transform: rotate(0deg);
  transition:
    transform 0.52s cubic-bezier(0.33, 1, 0.68, 1),
    opacity 0.32s ease;
}

.tag-cat-group.is-open .tag-cat-chevron {
  transform: rotate(90deg);
  opacity: 1;
}

.tag-cat-group:not(.is-open) .tag-cat-chevron {
  transition:
    transform 0.36s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.24s ease;
}

.tag-cat-head .tx-icon.colored-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 12px;
}

.tag-settings-members-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  flex-shrink: 0;
}

.tag-settings-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-cat-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.36s cubic-bezier(0.4, 0, 0.2, 1);
}

.tag-cat-group:not(.is-open) .tag-cat-body {
  pointer-events: none;
}

.tag-cat-group.is-open .tag-cat-body {
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.54s cubic-bezier(0.22, 1, 0.36, 1);
}

.tag-cat-list {
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  background: transparent;
  transition:
    opacity 0.22s cubic-bezier(0.4, 0, 1, 1),
    transform 0.34s cubic-bezier(0.4, 0, 0.2, 1);
}

.tag-cat-group.is-open .tag-cat-list {
  opacity: 1;
  transform: translateY(0);
  padding: 2px 0 4px;
  background: var(--surface-2);
  border-radius: 0 0 10px 10px;
  transition:
    opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1) 0.08s,
    transform 0.54s cubic-bezier(0.22, 1, 0.36, 1) 0.05s;
}

.tag-cat-group:nth-child(even).is-open .tag-cat-list {
  background: var(--surface);
}

.tag-cat-list .tag-list-item {
  border-bottom: 1px solid var(--border);
}

.tag-cat-list .tag-list-item:last-child {
  border-bottom: none;
}

#view-tags .tag-list-item .ws-list-activate {
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

#view-tags .tag-list-item--static .ws-list-activate {
  cursor: default;
}

#view-tags .tag-list-item .ws-list-title {
  font-size: 14px;
}

#view-tags .tag-list-item .ws-list-settings {
  width: 40px;
  border-left: none;
}

.tag-list-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.tag-settings-empty-row {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .tag-settings-toolbar:not(.is-search-open) .tx-search-line {
    display: none;
  }
}
