:root {
  --xs-tag-accent: var(--sv-accent, var(--bs-primary, #367c59));
  --xs-tag-paper: var(--sv-paper, var(--bs-body-bg, #fff));
  --xs-tag-ink: var(--bs-body-color, #27312c);
  --xs-tag-muted: var(--sv-muted, var(--bs-secondary-color, #68736d));
  --xs-tag-line: var(--sv-line, var(--bs-border-color, #dfe5e1));
}

.xs-tag-editor {
  position: relative;
  z-index: 8;
  margin: -4px 0 14px;
}

.xmd-editor-more > .xs-tag-editor-xmd {
  min-width: 112px;
  flex: 0 1 auto;
  margin: 0;
}

.xs-tag-editor-xmd .xs-tag-editor-bar {
  min-height: 30px;
}

.xs-tag-editor-xmd .xs-tag-trigger {
  height: 30px;
  border-color: transparent;
  font-size: 0.84rem;
  font-weight: 400;
}

.xs-tag-editor-xmd .xs-tag-selected {
  flex-basis: 220px;
}

.xs-tag-editor-xmd .xs-tag-picker {
  top: 35px;
  min-width: min(420px, 92vw);
}

.xs-tag-editor-bar {
  display: flex;
  min-height: 32px;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 7px;
}

.xs-tag-trigger {
  display: inline-flex;
  min-width: 112px;
  height: 32px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 9px;
  color: var(--xs-tag-muted);
  background: transparent;
  border: 1px solid var(--xs-tag-line);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
}

.xs-tag-trigger:hover,
.xs-tag-trigger:focus,
.xs-tag-editor.is-open .xs-tag-trigger {
  color: var(--xs-tag-accent);
  background: rgba(54, 124, 89, 0.07);
  border-color: var(--xs-tag-accent);
  outline: 0;
}

.xs-tag-trigger b {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  padding: 0 4px;
  color: #fff;
  background: var(--xs-tag-accent);
  border-radius: 9px;
  font-size: 10px;
  line-height: 18px;
}

.xs-tag-chevron {
  transition: transform 0.15s ease;
}

.xs-tag-editor.is-open .xs-tag-chevron {
  transform: rotate(180deg);
}

.xs-tag-selected {
  display: flex;
  min-width: 0;
  flex: 1 1 300px;
  flex-wrap: wrap;
  gap: 5px;
}

.xs-tag-selected-chip,
.xs-tag-chip {
  display: inline-flex;
  min-height: 24px;
  max-width: 160px;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  overflow: hidden;
  color: var(--xs-tag-color, var(--xs-tag-accent));
  background: color-mix(in srgb, var(--xs-tag-color, var(--xs-tag-accent)) 9%, var(--xs-tag-paper));
  border: 1px solid color-mix(in srgb, var(--xs-tag-color, var(--xs-tag-accent)) 28%, var(--xs-tag-line));
  border-radius: 4px;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@supports not (color: color-mix(in srgb, #000 20%, #fff)) {
  .xs-tag-selected-chip,
  .xs-tag-chip {
    background: var(--xs-tag-paper);
    border-color: var(--xs-tag-line);
  }
}

.xs-tag-selected-chip > span:first-child,
.xs-tag-chip > span:first-child {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  background: var(--xs-tag-color, var(--xs-tag-accent));
  border-radius: 50%;
}

.xs-tag-selected-chip > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.xs-tag-selected-chip button {
  display: inline-grid;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  padding: 0;
  place-items: center;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 3px;
  font-size: 9px;
}

.xs-tag-selected-chip button:hover,
.xs-tag-selected-chip button:focus {
  background: rgba(0, 0, 0, 0.08);
  outline: 0;
}

.xs-tag-picker {
  position: absolute;
  top: 38px;
  left: 0;
  width: min(420px, 100%);
  padding: 9px;
  background: var(--xs-tag-paper);
  border: 1px solid var(--xs-tag-line);
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(31, 43, 36, 0.16);
}

.xs-tag-picker[hidden] {
  display: none !important;
}

.xs-tag-search-wrap {
  display: grid;
  height: 36px;
  grid-template-columns: 28px 1fr 30px;
  align-items: center;
  color: var(--xs-tag-muted);
  border: 1px solid var(--xs-tag-line);
  border-radius: 5px;
}

.xs-tag-search-wrap:focus-within {
  color: var(--xs-tag-accent);
  border-color: var(--xs-tag-accent);
  box-shadow: 0 0 0 3px rgba(54, 124, 89, 0.1);
}

.xs-tag-search-wrap > i {
  text-align: center;
}

.xs-tag-search {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0;
  color: var(--xs-tag-ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
}

.xs-tag-search-clear {
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  color: var(--xs-tag-muted);
  background: transparent;
  border: 0;
  font-size: 10px;
}

.xs-tag-options {
  display: grid;
  max-height: 246px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-top: 8px;
  overflow-y: auto;
}

.xs-tag-option,
.xs-tag-create {
  display: grid;
  min-width: 0;
  min-height: 34px;
  grid-template-columns: 9px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  color: var(--xs-tag-ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  text-align: left;
  font-size: 12px;
}

.xs-tag-option:hover,
.xs-tag-option:focus,
.xs-tag-option[aria-selected="true"] {
  background: rgba(54, 124, 89, 0.07);
  border-color: var(--xs-tag-line);
  outline: 0;
}

.xs-tag-option[aria-selected="true"] {
  color: var(--xs-tag-color, var(--xs-tag-accent));
  border-color: var(--xs-tag-color, var(--xs-tag-accent));
}

.xs-tag-option-marker {
  width: 8px;
  height: 8px;
  background: var(--xs-tag-color, var(--xs-tag-accent));
  border-radius: 50%;
}

.xs-tag-option > span:nth-child(2),
.xs-tag-create > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xs-tag-create {
  width: 100%;
  margin-top: 7px;
  color: var(--xs-tag-accent);
  background: rgba(54, 124, 89, 0.06);
  border-color: var(--xs-tag-line);
}

.xs-tag-create[hidden],
.xs-tag-empty[hidden] {
  display: none !important;
}

.xs-tag-empty {
  padding: 22px 8px 14px;
  color: var(--xs-tag-muted);
  text-align: center;
  font-size: 12px;
}

.xs-tag-list {
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.xs-tag-layout-inline {
  display: inline-flex;
  max-width: 100%;
  margin-left: 6px;
  vertical-align: 1px;
}

.xs-tag-inline-group {
  display: inline-flex;
  min-width: 0;
  max-width: 100%;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.xs-tag-inline-group > .xs-tag-layout-inline {
  min-width: 0;
  margin-left: 0;
}

.xs-tag-layout-new-line {
  display: flex;
  width: 100%;
  margin: 5px 0 0;
}

.xs-tag-lines-1 {
  max-height: 20px;
  overflow: hidden;
}

.xs-tag-lines-2 {
  max-height: 44px;
  overflow: hidden;
}

.xs-tag-chip {
  min-height: 20px;
  max-width: 120px;
  padding: 1px 6px;
  vertical-align: 1px;
}

.xs-tag-chip:hover,
.xs-tag-chip:focus {
  color: var(--xs-tag-color, var(--xs-tag-accent));
  filter: brightness(0.82);
  text-decoration: none;
}

.xs-tag-thread-title {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: 8px;
  vertical-align: 3px;
}

.xs-tag-article-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 28px;
  padding-top: 12px;
  border-top: 1px solid var(--xs-tag-line);
}

.xs-tag-page {
  padding-top: 2px;
}

.xs-tag-page .xs-subforum-badge-list {
  display: none !important;
}

.xs-tag-page-head {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding: 13px 16px;
  background: var(--xs-tag-paper);
  border-bottom: 1px solid var(--xs-tag-line);
}

.xs-tag-page-head > div:first-child {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.xs-tag-page-head h1,
.xs-tag-page-head p {
  margin: 0;
}

.xs-tag-page-head h1 {
  color: var(--xs-tag-ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}

.xs-tag-page-head p {
  margin-top: 3px;
  overflow: hidden;
  color: var(--xs-tag-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xs-tag-page-icon,
.xs-tag-page-color {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  color: var(--xs-tag-accent);
  background: rgba(54, 124, 89, 0.1);
  border-radius: 6px;
}

.xs-tag-page-color {
  width: 9px;
  height: 40px;
  flex-basis: 9px;
  background: var(--xs-tag-color, var(--xs-tag-accent));
  border-radius: 3px;
}

.xs-tag-page-actions {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--xs-tag-muted);
  font-size: 12px;
}

.xs-tag-page-actions b {
  color: var(--xs-tag-ink);
  font-size: 15px;
}

.xs-tag-page-actions a {
  color: var(--xs-tag-accent);
  white-space: nowrap;
}

.xs-tag-directory {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.xs-tag-directory-item {
  display: grid;
  min-height: 62px;
  grid-template-columns: 7px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px;
  color: var(--xs-tag-ink);
  background: var(--xs-tag-paper);
  border: 1px solid var(--xs-tag-line);
  border-radius: 6px;
}

.xs-tag-directory-item:hover,
.xs-tag-directory-item:focus {
  color: var(--xs-tag-ink);
  border-color: var(--xs-tag-color, var(--xs-tag-accent));
  text-decoration: none;
}

.xs-tag-directory-color {
  width: 7px;
  height: 34px;
  background: var(--xs-tag-color, var(--xs-tag-accent));
  border-radius: 3px;
}

.xs-tag-directory-item > span:nth-child(2) {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.xs-tag-directory-item strong,
.xs-tag-directory-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xs-tag-directory-item strong {
  font-size: 13px;
}

.xs-tag-directory-item small {
  margin-top: 2px;
  color: var(--xs-tag-muted);
  font-size: 10px;
}

.xs-tag-directory-item b {
  display: inline-grid;
  min-width: 26px;
  height: 22px;
  place-items: center;
  padding: 0 5px;
  color: var(--xs-tag-muted);
  background: rgba(104, 115, 109, 0.08);
  border-radius: 4px;
  font-size: 10px;
}

.xs-tag-page-empty {
  display: flex;
  min-height: 220px;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  color: var(--xs-tag-muted);
  background: var(--xs-tag-paper);
  border: 1px solid var(--xs-tag-line);
}

.xs-tag-page-empty i {
  font-size: 26px;
}

@media (max-width: 575.98px) {
  .xs-tag-editor-bar {
    align-items: stretch;
  }
  .xs-tag-selected {
    width: 100%;
    flex-basis: 100%;
  }
  .xmd-editor-more > .xs-tag-editor-xmd {
    width: 100%;
    flex-basis: 100%;
  }
  .xs-tag-editor-xmd .xs-tag-editor-bar {
    width: 100%;
  }
  .xs-tag-editor-xmd .xs-tag-selected {
    width: auto;
    flex: 1 1 160px;
  }
  .xs-tag-picker {
    top: 38px;
    width: 100%;
  }
  .xs-tag-options {
    grid-template-columns: 1fr;
  }
  .xs-tag-list .xs-tag-chip {
    max-width: min(132px, 44vw);
  }
  .xs-tag-thread-title {
    max-width: 100%;
    margin-left: 5px;
  }
  .xs-tag-page-head {
    align-items: flex-start;
    flex-direction: column;
    padding: 11px 12px;
  }
  .xs-tag-page-actions {
    width: 100%;
    justify-content: space-between;
    padding-left: 20px;
  }
  .xs-tag-directory {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 576px) and (max-width: 991.98px) {
  .xs-tag-directory { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
  body.sv-mobile-thread-enhanced .threadlist .subject > .xs-tag-inline-group {
    width: 100%;
    flex: 1 0 100%;
    flex-wrap: nowrap;
    overflow: hidden;
  }

  body.sv-mobile-thread-enhanced .threadlist .xs-tag-inline-group > .sv-thread-badge {
    flex: 0 0 auto;
  }

  body.sv-mobile-thread-enhanced .threadlist .subject > .xs-tag-layout-inline {
    display: flex;
    min-width: 0;
    max-width: none;
    flex: 1 1 0;
    margin: 0;
  }

  body.sv-mobile-thread-enhanced .threadlist .xs-tag-inline-group > .xs-tag-layout-inline {
    display: flex;
    min-width: 0;
    max-width: none;
    flex: 1 1 0;
    flex-wrap: nowrap;
    margin: 0;
    overflow: hidden;
  }

  body.sv-mobile-thread-enhanced .threadlist .xs-tag-layout-inline.xs-tag-lines-1 {
    flex-wrap: nowrap;
  }

  body.sv-mobile-thread-enhanced .threadlist .xs-tag-layout-inline .xs-tag-chip {
    min-width: 0;
    max-width: 86px;
    flex: 0 0 auto;
    gap: 3px;
    padding: 1px 4px;
    font-size: 9px;
  }

  body.sv-mobile-thread-enhanced .threadlist .xs-tag-inline-group > .xs-tag-layout-inline .xs-tag-chip:nth-child(n+2) {
    display: none;
  }

  body.sv-mobile-thread-enhanced .threadlist .xs-tag-layout-inline .xs-tag-chip.xs-tag-fit-hidden {
    display: none !important;
  }

  body.sv-mobile-thread-enhanced .threadlist .xs-tag-layout-inline .xs-tag-chip > span:first-child {
    width: 5px;
    height: 5px;
    flex-basis: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .xs-tag-chevron { transition: none; }
}
