.tag-manager-shell[hidden],
.tag-confirm[hidden] {
  display: none;
}

.tag-manager-shell {
  align-items: stretch;
  background: rgb(4 8 24 / 46%);
  display: flex;
  inset: 0;
  justify-content: flex-end;
  position: fixed;
  z-index: 1900;
}

.tag-manager-panel button,
.tag-confirm button,
.asset-tags-section button {
  background: #fff;
  border: 1px solid rgb(90 33 232 / 20%);
  border-radius: 6px;
  color: #4a18cf;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 0 13px;
}

.tag-create-form button,
.tag-confirm-card footer > button:last-child,
.asset-tag-actions button {
  background: #4a18cf;
  color: #fff;
}

.tag-manager-panel button[disabled],
.tag-confirm button[disabled],
.asset-tags-section button[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}

.tag-manager-panel {
  background: #f8f9fd;
  box-shadow: -20px 0 54px rgb(15 23 42 / 20%);
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  width: min(620px, 92vw);
}

.tag-manager-header {
  align-items: flex-start;
  background: #fff;
  border-bottom: 1px solid #e4e7f0;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 24px 28px 20px;
}

.tag-manager-header h2 {
  color: #0b1029;
  font-size: 22px;
  letter-spacing: 0;
  margin: 4px 0;
}

.tag-manager-header p {
  color: #626a84;
  margin: 0;
}

.tag-manager-close {
  align-items: center;
  background: #f2f3f8;
  border: 1px solid #e1e3ec;
  border-radius: 6px;
  color: #1a2140;
  display: inline-flex;
  flex: 0 0 42px;
  font-size: 24px;
  height: 42px;
  justify-content: center;
  padding: 0;
  width: 42px;
}

.tag-create-form {
  background: #fff;
  border-bottom: 1px solid #e4e7f0;
  padding: 18px 28px;
}

.tag-create-form label {
  color: #343b57;
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

.tag-create-form > div {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.tag-create-form input,
.tag-manager-toolbar > input,
.tag-rename-form input,
.asset-tags-section > input {
  background: #fff;
  border: 1px solid #d9ddea;
  border-radius: 6px;
  color: #141a37;
  height: 42px;
  min-width: 0;
  padding: 0 12px;
}

.tag-manager-toolbar {
  align-items: center;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 16px 28px 8px;
}

.tag-manager-tabs {
  background: #eceefa;
  border-radius: 6px;
  display: flex;
  padding: 3px;
}

.tag-manager-tabs button {
  background: transparent;
  border: 0;
  color: #59617a;
  min-height: 36px;
  padding: 0 13px;
}

.tag-manager-tabs button.active {
  background: #fff;
  box-shadow: 0 1px 3px rgb(15 23 42 / 12%);
  color: #2f0eb6;
}

.tag-manager-notice {
  color: #656d86;
  margin: 0;
  min-height: 24px;
  padding: 4px 28px 10px;
}

.tag-manager-notice[data-tone="error"],
.asset-tag-notice[data-tone="error"] {
  color: #b42318;
}

.tag-manager-notice[data-tone="warning"],
.asset-tag-notice[data-tone="warning"] {
  color: #9a6700;
}

.tag-manager-notice[data-tone="success"],
.asset-tag-notice[data-tone="success"] {
  color: #067647;
}

.tag-manager-list {
  min-height: 0;
  overflow-y: auto;
  padding: 0 28px;
}

.tag-dictionary-row {
  align-items: center;
  background: #fff;
  border: 1px solid #e3e6ef;
  border-radius: 6px;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 9px;
  min-width: 0;
  padding: 14px 15px;
}

.tag-dictionary-content {
  min-width: 0;
}

.tag-dictionary-name-row {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.tag-dictionary-name-row strong {
  color: #111735;
  overflow-wrap: anywhere;
}

.tag-status {
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 7px;
  text-transform: uppercase;
}

.tag-status.active {
  background: #e9f8ef;
  color: #067647;
}

.tag-status.archived {
  background: #eef0f5;
  color: #697087;
}

.tag-usage-count {
  color: #697087;
  display: block;
  font-size: 12px;
  margin-top: 5px;
}

.tag-dictionary-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
}

.tag-dictionary-actions button,
.tag-manager-footer button,
.asset-tag-actions button,
.asset-tags-heading-row button,
.asset-tag-options button {
  min-height: 38px;
}

.tag-dictionary-actions .danger-action {
  color: #b42318;
}

.tag-rename-form {
  display: grid;
  gap: 7px;
  grid-template-columns: minmax(120px, 1fr) auto auto;
}

.tag-manager-footer {
  background: #fff;
  border-top: 1px solid #e4e7f0;
  padding: 14px 28px calc(14px + env(safe-area-inset-bottom));
}

.tag-empty-state {
  color: #68718a;
  margin: 32px auto;
  max-width: 360px;
  text-align: center;
}

.tag-confirm {
  align-items: center;
  background: rgb(4 8 24 / 56%);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 2000;
}

.tag-confirm-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgb(7 12 32 / 30%);
  max-width: 440px;
  padding: 24px;
  width: 100%;
}

.tag-confirm-card h2 {
  color: #101632;
  font-size: 20px;
  letter-spacing: 0;
  margin: 5px 0 10px;
}

.tag-confirm-card p {
  color: #626a84;
  line-height: 1.55;
}

.tag-confirm-card footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
}

.tag-manager-open {
  overflow: hidden;
}

.asset-tags-heading-row {
  align-items: flex-start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.asset-tag-notice {
  color: #626a84;
  margin: 0 0 14px;
  min-height: 20px;
}

.asset-tag-historical,
.asset-tag-selected {
  background: #fff;
  border: 1px solid #e3e6ef;
  border-radius: 6px;
  margin-bottom: 14px;
  padding: 14px 15px;
}

.asset-tag-historical p {
  color: #697087;
  font-size: 12px;
  margin: 4px 0 10px;
}

.asset-tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.asset-tag-chip {
  align-items: center;
  background: #eeeaff;
  border-radius: 999px;
  color: #3413ac;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 5px;
  max-width: 100%;
  padding: 5px 9px;
  overflow-wrap: anywhere;
}

.asset-tag-chip.historical {
  background: #eef0f5;
  color: #60677d;
}

.asset-tag-chip button {
  background: transparent;
  border: 0;
  color: currentcolor;
  font-size: 17px;
  min-height: 22px;
  padding: 0;
}

.asset-tag-empty {
  color: #707890;
  font-size: 13px;
}

.asset-tags-section > input {
  margin-bottom: 12px;
  width: 100%;
}

.asset-tag-options {
  border: 1px solid #e2e5ee;
  border-radius: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.asset-tag-option {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #eceef4;
  display: flex;
  gap: 10px;
  min-height: 48px;
  padding: 10px 13px;
}

.asset-tag-option:last-child {
  border-bottom: 0;
}

.asset-tag-option input {
  flex: 0 0 auto;
  height: 18px;
  width: 18px;
}

.asset-tag-option span {
  display: flex;
  justify-content: space-between;
  min-width: 0;
  width: 100%;
}

.asset-tag-option strong {
  color: #171d3a;
  overflow-wrap: anywhere;
}

.asset-tag-option small {
  color: #747b91;
  flex: 0 0 auto;
}

.asset-tag-actions {
  border-top: 1px solid #e1e4ed;
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 18px;
}

.tag-manager-panel button:focus-visible,
.tag-manager-panel input:focus-visible,
.tag-confirm button:focus-visible,
.asset-tags-section button:focus-visible,
.asset-tags-section input:focus-visible {
  outline: 3px solid rgb(64 24 220 / 28%);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .tag-manager-panel {
    height: 100dvh;
    width: 100%;
  }

  .tag-confirm-card.media-dialog-surface {
    min-height: auto;
  }

  .tag-manager-header {
    padding:
      calc(16px + env(safe-area-inset-top))
      18px
      16px;
  }

  .tag-create-form,
  .tag-manager-list {
    padding-inline: 18px;
  }

  .tag-manager-toolbar {
    align-items: stretch;
    grid-template-columns: 1fr;
    padding: 14px 18px 8px;
  }

  .tag-manager-tabs button {
    flex: 1;
  }

  .tag-manager-notice {
    padding-inline: 18px;
  }

  .tag-dictionary-row {
    align-items: stretch;
    flex-direction: column;
  }

  .tag-dictionary-actions,
  .tag-dictionary-actions > button {
    width: 100%;
  }

  .tag-dictionary-actions > button {
    min-height: 44px;
  }

  .tag-rename-form {
    grid-template-columns: 1fr 1fr;
  }

  .tag-rename-form input {
    grid-column: 1 / -1;
  }

  .tag-manager-footer {
    padding-inline: 18px;
  }

  .asset-tags-heading-row {
    align-items: stretch;
    flex-direction: column;
  }

  .asset-tags-heading-row button,
  .asset-tag-actions button {
    min-height: 44px;
    width: 100%;
  }

  .asset-tag-option {
    min-height: 52px;
  }

  .asset-tag-option span {
    align-items: flex-start;
    flex-direction: column;
  }
}
