/* vrc.dj  Tag Editor Dashboard */

/* Scope the page accent to the livesets amber (#f59e0b) so the queue
   identity reads as a moderation/curation surface rather than the
   global purple. All themed elements below resolve var(--accent) to
   this scoped value; the per-tag computed colors on the inspector are
   unaffected because they don't reference --accent. */
.te-page-wrap {
    --accent-base:        #f59e0b;
    --accent:             #f59e0b;
    --accent-bright:      color-mix(in srgb, #f59e0b 75%, white);
    --accent-glow:        color-mix(in srgb, #f59e0b 25%, transparent);
    --accent-neutralized: color-mix(in srgb, #f59e0b 20%, #808080);
}
[data-theme="light"] .te-page-wrap {
    --accent:        color-mix(in srgb, #f59e0b 85%, black);
    --accent-bright: #f59e0b;
    --accent-glow:   color-mix(in srgb, #f59e0b 15%, transparent);
}

/* -- Toolbar (filter pills + sort) ------------------------------------ */
.te-toolbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .4rem;
}
.te-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
}
.te-sorts {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.te-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: .2rem .55rem;
    border-radius: 5px;
    font-size: .76rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--bg-card) 80%, transparent);
    border: 1px solid var(--border);
    transition: background .12s, border-color .12s, color .12s;
    white-space: nowrap;
    line-height: 1.3;
}
.te-pill:hover {
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-card));
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
    color: var(--text);
}
.te-pill--active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.te-pill--active:hover { filter: brightness(1.1); color: #fff; }
.te-pill--warn:not(.te-pill--active)  .te-pill-count { color: #f59e0b; }
.te-pill--danger:not(.te-pill--active) .te-pill-count { color: #ef4444; }
.te-pill-count {
    font-weight: 700;
    font-size: .72rem;
    opacity: .85;
}
.te-pill--active .te-pill-count { opacity: 1; color: inherit; }
.te-pill--sort {
    font-weight: 400;
    font-size: .72rem;
    padding: .18rem .45rem;
}

/* -- Full-height layout ----------------------------------------------- */
.te-layout {
    display: grid;
    grid-template-columns: 1fr 430px;
    grid-template-rows: minmax(0, 1fr);
    gap: .65rem;
    /* Fill remaining viewport below the hero + controls */
    min-height: 0;
    flex: 1;
}
/* Settings page wrapper must be a flex column for this to stretch */
.te-page-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 348px);
    min-height: 480px;
}
.te-inspector-pane .tag-admin-field {
    margin-bottom: 5px;
}
.te-inspector-pane .tag-admin-section {
    margin-bottom: 4px;
}
@media (max-width: 992px) {
    .te-layout { grid-template-columns: 1fr; gap: .5rem; }
    .te-page-wrap { height: auto; min-height: unset; }

    .te-queue-pane { max-height: 55vh; }

    .te-toolbar { gap: .3rem; margin-bottom: .3rem; }
    .te-pill { padding: .16rem .45rem; font-size: .72rem; }
    .te-pill--sort { padding: .14rem .4rem; font-size: .7rem; }
    .te-pill-count { font-size: .68rem; }

    .te-queue-table tbody tr,
    .te-queue-table tbody td { height: 30px; }
    .te-queue-table tbody td { padding: .1rem .4rem; }
    .te-queue-table thead th { padding: .3rem .4rem; }

    .te-pagination-row { padding: .25rem .5rem; font-size: .75rem; }
    .te-page-pill { min-width: 64px; font-size: .7rem; padding: .15rem .35rem; }
    .te-pp-select { font-size: .68rem; }
    .te-quick-input { width: 130px; font-size: .74rem; }

    .te-inspector-pane { overflow: visible; max-height: none; }
    .te-inspector-body { overflow-y: visible; max-height: none; }
    .te-inspector-footer {
        position: sticky;
        bottom: 0;
        z-index: 5;
        background: color-mix(in srgb, var(--bg-card) 94%, var(--bg-base));
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        padding-block: 8px;
    }
    .te-dirty-bar { position: sticky; bottom: 44px; z-index: 5; }

    .te-shortcuts { display: none; }
}

@media (max-width: 576px) {
    .te-pp-select { display: none; }
    .te-pagination-row { gap: .3rem; }
    .te-page-pill { min-width: 56px; }
    .te-quick-input { width: 100%; }
    .te-quick-create { flex: 1 1 100%; order: -1; margin-bottom: .25rem; }
}

/* -- Queue pane ------------------------------------------------------- */
.te-queue-pane {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    min-height: 0; /* allow shrink in flex */
    display: flex;
    flex-direction: column;
}
.te-queue-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
}
.te-queue-table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: color-mix(in srgb, var(--accent) 8%, transparent);
    margin: 0;
    width: 100%;
    table-layout: fixed;
    font-size: .85rem;
}
.te-queue-table thead th {
    position: sticky;
    top: 0;
    background: color-mix(in srgb, var(--bg-elevated) 82%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 4;
    border-bottom: 1px solid var(--border);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    padding: .35rem .5rem;
}
.te-queue-table tbody tr {
    height: 32px;
}
.te-queue-table tbody td {
    padding: .1rem .5rem;
    height: 32px;
    vertical-align: middle;
    border-color: var(--border);
    overflow: hidden;
}
.te-tag-cell,
.te-category-cell {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: .35rem;
}
.te-tag-label,
.te-tag-slug {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.te-tag-label {
    font-weight: 500;
}
.te-tag-slug {
    flex: 0 1 auto;
}
.te-category-cell {
    white-space: nowrap;
}

.te-pagination-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .35rem .6rem;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-card) 75%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-shrink: 0;
    font-size: .8rem;
}
.te-pagination-controls {
    display: flex;
    align-items: center;
    gap: .4rem;
}
.te-page-pill {
    font-size: .75rem;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: .2rem .45rem;
    min-width: 82px;
    text-align: center;
}
.te-pp-select {
    font-size: .72rem;
    padding: .15rem .3rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    margin-left: .25rem;
}

/* Quick-create inline input */
.te-quick-create {
    display: flex;
    align-items: center;
}
.te-quick-input {
    font-size: .78rem;
    padding: .2rem .45rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    width: 150px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.te-quick-input::placeholder {
    color: var(--text-muted);
    opacity: .6;
}
.te-quick-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}
.te-quick-input:disabled {
    opacity: .5;
}

/* Flash animation for newly created rows */
.te-new-flash {
    animation: teNewFlash .6s ease-out;
}
@keyframes teNewFlash {
    0%   { background: color-mix(in srgb, var(--accent) 30%, transparent); }
    100% { background: transparent; }
}

/* -- Row states ------------------------------------------------------- */
.te-row { cursor: pointer; transition: background .12s; }
.te-row--active {
    background: color-mix(in srgb, var(--accent) 12%, transparent) !important;
    border-left: 3px solid var(--accent);
}
.te-row--active td:first-child { padding-left: calc(.5rem - 3px); }

/* -- Health indicators ------------------------------------------------ */
.te-health-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.te-health-dot--critical { background: #ef4444; }
.te-health-dot--warning  { background: #f59e0b; }
.te-health-dot--healthy  { background: #22c55e; }

.te-health-chip {
    display: inline-block;
    padding: .1rem .4rem;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 600;
}
.te-health-chip--critical { background: color-mix(in srgb, #ef4444 20%, transparent); color: #fca5a5; }
.te-health-chip--warning  { background: color-mix(in srgb, #f59e0b 20%, transparent); color: #fcd34d; }
.te-health-chip--healthy  { background: color-mix(in srgb, #22c55e 20%, transparent); color: #86efac; }

/* -- Badges ----------------------------------------------------------- */
.te-cat-badge {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .7rem;
    font-weight: 500;
    padding: .15rem .45rem;
    border-radius: 4px;
    color: #fff;
    background: var(--accent);
}
.te-status-badge {
    font-size: .7rem;
    padding: .15rem .4rem;
    border-radius: 4px;
    font-weight: 500;
}
.te-status--published    { background: color-mix(in srgb, #22c55e 20%, transparent); color: #86efac; }
.te-status--needs_review { background: color-mix(in srgb, #f59e0b 20%, transparent); color: #fcd34d; }
.te-status--draft        { background: color-mix(in srgb, #6b7280 20%, transparent); color: #d1d5db; }

/* -- Inspector pane (reuses tag-admin-* classes from panels.css) ------ */
.te-inspector-pane {
    background: color-mix(in srgb, var(--bg-card) 60%, transparent);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: auto;
    min-height: 0;
}
.te-inspector-header {
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
[data-theme="light"] .te-inspector-header { border-bottom-color: rgba(0,0,0,0.10); }
.te-inspector-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}
.te-inspector-slug a { text-decoration: none; }
.te-inspector-slug a:hover { color: var(--accent) !important; }

.te-inspector-body {
    overflow-y: auto;
    padding: 8px 14px;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.te-context-top {
    border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--bg-elevated) 40%, transparent);
    padding: .35rem .65rem;
    margin-bottom: .5rem;
}

.te-context-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .7rem;
    font-size: .78rem;
    padding: .08rem 0;
}

.te-context-value {
    flex: 1;
    text-align: right;
    line-height: 1.35;
}

.te-context-link {
    color: var(--text);
    text-decoration: none;
    max-width: 65%;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.te-context-link:hover {
    color: var(--accent);
}

.te-context-health {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: .45rem;
    flex-wrap: wrap;
}

/* -- Inspector footer (save/discard) ---------------------------------- */
.te-inspector-footer {
    flex-shrink: 0;
    padding: 6px 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 6px;
}
[data-theme="light"] .te-inspector-footer { border-top-color: rgba(0,0,0,0.10); }
.te-inspector-footer .btn {
    min-width: 0;
    padding-left: .55rem;
    padding-right: .55rem;
}
.te-inspector-footer .btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.te-inspector-footer .btn-accent:disabled { opacity: .5; }

/* -- Dirty bar -------------------------------------------------------- */
.te-dirty-bar {
    display: none;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .3rem .75rem;
    background: color-mix(in srgb, #f59e0b 15%, var(--bg-card));
    border-top: 1px solid #f59e0b;
    font-size: .78rem;
    color: #fcd34d;
    flex-shrink: 0;
}
.te-dirty-bar--visible { display: flex; }

/* -- Shortcut hints --------------------------------------------------- */
.te-shortcuts {
    text-align: center;
    opacity: .5;
    font-size: .72rem;
    margin-top: .35rem;
    flex-shrink: 0;
}
.te-shortcuts kbd {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: .05rem .25rem;
    font-size: .7rem;
}

/* -- Tag Groups modal ------------------------------------------------- */
.te-pill--groups {
    border-color: #8b5cf6 !important;
    color: #8b5cf6;
}
.te-pill--groups:hover,
.te-pill--groups:focus {
    background: color-mix(in srgb, #8b5cf6 18%, transparent);
    color: #c4b5fd;
}
/* Add-group composer */
.te-grp-add { margin-bottom: 1rem; }
.te-grp-add-row {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
    padding: .5rem .5rem .5rem .6rem;
    background: var(--bg-card);
    border: 1px dashed var(--border-bright);
    border-radius: var(--radius);
}
.te-grp-add-row input[type="text"] {
    flex: 1 1 140px;
    min-width: 100px;
    height: 2.1rem;
}
.te-grp-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.te-grp-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
    padding: .8rem 1rem 1rem;
    border-top: 1px solid color-mix(in srgb, var(--border) 30%, transparent);
}

/* Group card */
.te-grp-row {
    --c: #8b5cf6;
    position: relative;
    border-radius: var(--radius);
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--c) 9%, transparent), transparent 34%),
        var(--bg-card);
    border: 1px solid var(--border);
    transition: border-color .18s var(--ease), background .18s var(--ease);
}
.te-grp-row::before {
    content: "";
    position: absolute;
    left: 0; top: 7px; bottom: 7px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--c);
    box-shadow: 0 0 12px color-mix(in srgb, var(--c) 55%, transparent);
}
.te-grp-row:hover { border-color: var(--border-bright); }
.te-grp-row--open { border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }
.te-grp-row--dirty {
    border-color: color-mix(in srgb, #f59e0b 55%, var(--border));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, #f59e0b 16%, transparent);
}
.te-grp-row--new::before { background: #22c55e; box-shadow: 0 0 12px rgba(34,197,94,.5); }
.te-grp-row--deleted { opacity: .55; }
.te-grp-row--deleted .te-grp-main { pointer-events: none; }
.te-grp-row--deleted .te-grp-name { text-decoration: line-through; }

/* Main line */
.te-grp-main {
    display: flex;
    align-items: center;
    gap: .3rem .55rem;
    padding: .35rem .5rem .35rem .8rem;
    flex-wrap: wrap;
}

/* Colour swatch = the picker; always shows the live colour */
.te-grp-swatch {
    position: relative;
    flex: 0 0 auto;
    width: 28px; height: 28px;
    border-radius: 8px;
    cursor: pointer;
    background: var(--c);
    border: 1px solid rgba(255,255,255,.22);
    box-shadow: inset 0 0 0 2px rgba(0,0,0,.25), 0 1px 4px rgba(0,0,0,.4);
    transition: transform .16s var(--ease);
}
.te-grp-swatch:hover { transform: scale(1.07); }
.te-grp-swatch::after {
    content: "";
    position: absolute;
    right: -3px; bottom: -3px;
    width: 13px; height: 13px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-bright);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='9' height='9' viewBox='0 0 16 16' fill='none' stroke='%238b98ac' stroke-width='2' stroke-linecap='round'><path d='M11 2l3 3-8 8-4 1 1-4z'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
}
.te-grp-color {
    position: absolute !important;
    inset: 0;
    width: 100% !important; height: 100% !important;
    min-height: 0 !important;
    margin: 0; padding: 0 !important;
    opacity: 0; cursor: pointer;
    border: 0 !important; background: transparent !important;
}

/* Name (specificity bumped so it beats .vrcdj-modal-input regardless of load order) */
.te-grp-row .te-grp-name {
    flex: 1 1 110px;
    min-width: 80px;
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: .3rem .45rem;
    height: auto;
    transition: .16s var(--ease);
}
.te-grp-row .te-grp-name:hover { background: rgba(255,255,255,.03); }
.te-grp-row .te-grp-name:focus {
    outline: none;
    background: rgba(255,255,255,.06);
    border-color: color-mix(in srgb, var(--c) 60%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 15%, transparent);
}

/* Count pill, themed by the group colour */
.te-grp-count {
    flex: 0 0 auto;
    font-size: .7rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #fff;
    line-height: 1;
    padding: .2rem .5rem;
    border-radius: 999px;
    min-width: 1.9rem;
    text-align: center;
    white-space: nowrap;
    background: color-mix(in srgb, var(--c) 82%, #000 8%);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}

/* Action cluster */
.te-grp-acts { display: flex; align-items: center; gap: .1rem; flex: 0 0 auto; }
.te-grp-row .dropdown { line-height: 0; }
.te-grp-btn {
    width: 29px; height: 29px;
    padding: 0;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    color: var(--text-muted);
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: .15s var(--ease);
}
.te-grp-btn i { font-size: .95rem; line-height: 1; }
.te-grp-btn:hover { background: var(--bg-card-hover); color: var(--text); border-color: var(--border); }
.te-grp-btn.te-grp-del-btn:hover { color: #f87171; border-color: color-mix(in srgb, #f87171 40%, transparent); }
.te-grp-row .dropdown .te-grp-btn:hover { color: #fbbf24; }
.te-grp-expand i { transition: transform .22s var(--ease); }
.te-grp-row--open .te-grp-expand {
    color: var(--c);
    background: color-mix(in srgb, var(--c) 14%, transparent);
    border-color: color-mix(in srgb, var(--c) 35%, transparent);
}
.te-grp-row--open .te-grp-expand i { transform: rotate(180deg); }
.te-grp-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-right: .4rem;
    vertical-align: middle;
}

/* Divider above the virtual "Unsorted" system row */
.te-grp-divider {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: .35rem 0 .1rem;
    color: var(--text-muted);
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.te-grp-divider::before,
.te-grp-divider::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: color-mix(in srgb, var(--border) 70%, transparent);
}

/* Virtual "Unsorted" pseudo-category row - no name/color/sort/delete/merge,
   just the four capability toggles (see tag_unsorted_category_settings()). */
.te-grp-row--system .te-grp-swatch { cursor: default; }
.te-grp-row--system .te-grp-swatch::after { display: none; }
.te-grp-row--system .te-grp-color { pointer-events: none; }
.te-grp-row--system .te-grp-name:disabled { color: var(--text-muted); cursor: default; }
.te-grp-row--system .te-grp-del-btn:disabled { opacity: .3; cursor: not-allowed; }
.te-grp-row--system .te-grp-del-btn:disabled:hover { background: none; color: var(--text-muted); border-color: transparent; }
.te-grp-sys-badge {
    flex: 0 0 auto;
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--border) 45%, transparent);
    padding: .15rem .45rem;
    border-radius: 999px;
    white-space: nowrap;
}

/* Settings drawer (animated) */
.te-grp-settings {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .26s var(--ease);
}
.te-grp-row--open .te-grp-settings { grid-template-rows: 1fr; }
.te-grp-settings-in { overflow: hidden; }
.te-grp-settings-pad {
    display: flex;
    flex-direction: column;
    gap: .55rem;
    padding: .7rem .8rem .75rem;
    margin: 0 .1rem;
    border-top: 1px solid var(--border);
}
.te-grp-sortrow { display: flex; align-items: center; gap: .6rem; }
.te-grp-sortrow label { font-size: .75rem; font-weight: 600; color: var(--text-secondary); margin: 0; }
.te-grp-sort {
    width: 64px !important;
    flex: 0 0 64px;
    height: 1.9rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.te-grp-caps { display: flex; flex-direction: column; gap: .1rem; }
.te-grp-cap {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .35rem .35rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: .85rem;
    color: var(--text-secondary);
    user-select: none;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.te-grp-cap:hover { background: rgba(255,255,255,.03); }
.te-grp-cap:has(input:checked) { color: var(--text); }
.te-grp-cap > span:first-child { flex: 1 1 auto; }

/* Toggle switch */
.te-grp-sw { position: relative; flex: 0 0 auto; width: 38px; height: 22px; }
.te-grp-sw input {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    margin: 0; opacity: 0; cursor: pointer; z-index: 2;
}
.te-grp-track {
    position: absolute; inset: 0;
    border-radius: 999px;
    background: rgba(255,255,255,.12);
    border: 1px solid var(--border);
    transition: .2s var(--ease);
}
.te-grp-knob {
    position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #cbd5e1;
    box-shadow: 0 1px 3px rgba(0,0,0,.5);
    transition: .2s var(--ease);
}
.te-grp-sw input:checked ~ .te-grp-track {
    background: color-mix(in srgb, #34d399 62%, transparent);
    border-color: color-mix(in srgb, #34d399 70%, transparent);
}
.te-grp-sw input:checked ~ .te-grp-knob { transform: translateX(16px); background: #fff; }
.te-grp-sw input:focus-visible ~ .te-grp-track { box-shadow: 0 0 0 3px color-mix(in srgb, #34d399 30%, transparent); }
.te-grp-row--deleted .te-grp-settings { pointer-events: none; }

@media (max-width: 576px) {
    .te-grp-main { gap: .35rem .5rem; }
    .te-grp-name { flex: 1 1 90px; order: 1; }
    .te-grp-swatch { order: 0; }
    .te-grp-count { order: 2; }
    .te-grp-acts { order: 3; flex: 1 1 100%; justify-content: flex-end; }
    .te-grp-btn { width: 34px; height: 34px; }
    .te-grp-footer { padding-inline: .75rem; }
}

[data-theme="light"] .te-grp-cap { color: var(--text-muted); }
[data-theme="light"] .te-grp-cap:has(input:checked) { color: var(--text); }
[data-theme="light"] #tagGroupsModal .te-grp-row--new::before { background: #16a34a; }

/* -- Light theme overrides -------------------------------------------- */
[data-theme="light"] .te-health-chip--critical { background: color-mix(in srgb, #ef4444 15%, transparent); color: #b91c1c; }
[data-theme="light"] .te-health-chip--warning  { background: color-mix(in srgb, #f59e0b 15%, transparent); color: #92400e; }
[data-theme="light"] .te-health-chip--healthy   { background: color-mix(in srgb, #22c55e 15%, transparent); color: #166534; }
[data-theme="light"] .te-status--published     { background: color-mix(in srgb, #22c55e 15%, transparent); color: #166534; }
[data-theme="light"] .te-status--needs_review  { background: color-mix(in srgb, #f59e0b 15%, transparent); color: #92400e; }
[data-theme="light"] .te-status--draft         { background: color-mix(in srgb, #6b7280 15%, transparent); color: #374151; }
[data-theme="light"] .te-inspector-pane {
    background: color-mix(in srgb, var(--bg-card) 85%, transparent);
}
[data-theme="light"] .te-dirty-bar {
    background: color-mix(in srgb, #f59e0b 10%, var(--bg-card));
    color: #92400e;
}

/* -------------------------------------------------------------------------
   Moderator Activity banner + modal
   ------------------------------------------------------------------------- */

.te-activity-banner {
    position: relative;
    display: grid;
    grid-template-columns: minmax(140px, .85fr) minmax(190px, 1fr) minmax(210px, 1.15fr) minmax(220px, 1.15fr);
    gap: 0;
    align-items: stretch;
    margin: 1rem 0 1.1rem;
    padding: .9rem 1.15rem;
    background: color-mix(in srgb, var(--bg-card) 62%, transparent);
    backdrop-filter: blur(18px) saturate(1.35);
    -webkit-backdrop-filter: blur(18px) saturate(1.35);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.06);
    overflow: visible;
    --te-act-color: var(--accent);
    cursor: pointer;
    transition: border-color .2s var(--ease, ease), transform .2s var(--ease, ease), box-shadow .2s var(--ease, ease);
}
.te-activity-banner::before,
.te-activity-banner::after {
    content: '';
    position: absolute;
    pointer-events: none;
    border-radius: inherit;
}
.te-activity-banner::before {
    inset: 0;
    background: radial-gradient(circle at 82% 30%, color-mix(in srgb, var(--te-act-color) 26%, transparent), transparent 56%);
    opacity: .7;
}
.te-activity-banner::after {
    inset: 0;
    background:
        radial-gradient(circle at 6% 50%, color-mix(in srgb, var(--te-act-color) 18%, transparent), transparent 38%),
        radial-gradient(circle at 88% 16%, color-mix(in srgb, var(--te-act-color) 14%, transparent), transparent 32%),
        linear-gradient(120deg, color-mix(in srgb, var(--te-act-color) 8%, transparent), transparent 38%, transparent 58%, color-mix(in srgb, var(--te-act-color) 5%, transparent));
}
.te-activity-banner > * { position: relative; z-index: 1; }
.te-activity-banner:hover,
.te-activity-banner:focus-visible {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--te-act-color) 30%, rgba(255,255,255,.08));
    box-shadow: 0 24px 70px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.08);
    outline: none;
}
.te-activity-banner > .te-act-zone + .te-act-zone {
    border-left: 1px solid color-mix(in srgb, var(--border) 35%, transparent);
}
.te-activity-banner--neutral {
    --te-act-color: color-mix(in srgb, var(--text-muted) 80%, var(--border));
    margin-top: 1rem;
}
.te-act-zone {
    padding: .15rem .8rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}
.te-act-zone:first-of-type { padding-left: .25rem; }
.te-act-zone:last-of-type  { padding-right: .25rem; }

/* Zone 0: identity (eyebrow + icon + title) */
.te-act-zone--identity {
    gap: .25rem;
    padding-right: 1rem;
}
.te-act-eyebrow {
    margin: 0;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--te-act-color) 70%, var(--text-muted));
    line-height: 1;
}
.te-act-title {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.05;
    letter-spacing: -.01em;
    min-width: 0;
}
.te-act-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 1.85rem;
    flex: 0 0 auto;
    border-radius: 9px;
    background: color-mix(in srgb, var(--te-act-color) 18%, transparent);
    color: var(--te-act-color);
    font-size: 1rem;
}
.te-act-title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.te-activity-banner--neutral .te-act-eyebrow { color: var(--text-muted); }
.te-activity-banner--neutral .te-act-title-icon {
    background: color-mix(in srgb, var(--text-muted) 18%, transparent);
    color: var(--text-secondary);
}

/* Tiny window picker � notched into the top-right border (inspired by .ltc-show-all) */
.te-act-window-picker {
    position: absolute;
    top: 0;
    right: 1rem;
    transform: translateY(-50%);
    z-index: 2;
}
.te-act-window-trigger {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    padding: .12rem .42rem;
    background: var(--bg-base);
    border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
    border-radius: 999px;
    font-size: .58rem;
    font-weight: 600;
    letter-spacing: .03em;
    color: var(--text-muted);
    line-height: 1.5;
    cursor: pointer;
    white-space: nowrap;
    opacity: .55;
    transition: opacity .15s, color .15s, border-color .15s;
}
.te-activity-banner:hover .te-act-window-trigger,
.te-activity-banner:focus-within .te-act-window-trigger,
.te-act-window-trigger:focus-visible,
.te-act-window-picker.is-open .te-act-window-trigger {
    opacity: 1;
}
.te-act-window-trigger:hover {
    color: var(--text-secondary);
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.te-act-window-caret { font-size: .55rem; opacity: .7; }
.te-act-window-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    padding: .25rem;
    background: color-mix(in srgb, var(--bg-elevated) 82%, transparent);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.06);
    min-width: 90px;
    z-index: var(--z-dropdown, 30);
}
.te-act-window-picker.is-open .te-act-window-menu { display: flex; flex-direction: column; gap: 2px; }
.te-act-window-opt {
    display: block;
    width: 100%;
    padding: .25rem .55rem;
    background: transparent;
    border: 0;
    border-radius: 6px;
    font-size: .72rem;
    font-weight: 600;
    text-align: left;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background .12s, color .12s;
}
.te-act-window-opt:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); }
.te-act-window-opt.is-active { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); }

.te-act-window-readout {
    /* Hidden by default � the picker pill in the top-right already shows the active window. */
    display: none;
}

/* Zone A � stat trio */
.te-act-zone--stats {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    flex-wrap: nowrap;
}
.te-act-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .05rem;
    min-width: 52px;
}
.te-act-stat i {
    font-size: .85rem;
    color: var(--accent);
    margin-bottom: .15rem;
}
.te-act-stat--submitters i { color: color-mix(in srgb, var(--accent) 60%, #c084fc); }
.te-act-stat--created i  { color: color-mix(in srgb, var(--accent) 70%, #4ade80); }
.te-act-stat--published i { color: color-mix(in srgb, var(--accent) 60%, #facc15); }
.te-act-stat-num {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
}
.te-act-stat-label {
    font-size: .68rem;
    color: var(--text-muted);
    letter-spacing: .03em;
    text-transform: uppercase;
}

/* Zone B � sparkline */
.te-act-zone--spark {}
.te-act-spark-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .35rem;
}
.te-act-spark-title {
    font-size: .7rem;
    color: var(--text-muted);
    letter-spacing: .04em;
    text-transform: uppercase;
}
.te-act-spark-total {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.te-act-spark {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 38px;
}
.te-act-spark-bar {
    flex: 1;
    min-height: 2px;
    background: linear-gradient(to top,
        color-mix(in srgb, var(--accent) 35%, transparent),
        color-mix(in srgb, var(--accent) 85%, transparent));
    border-radius: 2px 2px 0 0;
    transition: opacity .15s;
}
.te-act-spark-bar:hover { opacity: .85; }
.te-act-spark-bar.is-empty {
    background: color-mix(in srgb, var(--border) 30%, transparent);
}

/* Zone C � top-3 podium */
.te-act-zone--podium { gap: .15rem; }
.te-act-podium-head {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .7rem;
    color: var(--text-muted);
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: .2rem;
}
.te-act-podium-head i { color: var(--accent); }
.te-act-podium-row {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .12rem .25rem;
    border-radius: 6px;
    font-size: .82rem;
    transition: background .15s;
}
.te-act-podium-row.is-me {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent);
}
.te-act-rank {
    font-size: .7rem;
    font-weight: 700;
    color: var(--text-muted);
    width: 1.2rem;
}
.te-act-podium-row--rank-1 .te-act-rank { color: color-mix(in srgb, var(--text), gold 35%); }
.te-act-podium-row--rank-2 .te-act-rank { color: color-mix(in srgb, var(--text), silver 30%); }
.te-act-podium-row--rank-3 .te-act-rank { color: color-mix(in srgb, var(--text), #cd7f32 40%); }
.te-act-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.te-act-avatar--initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .58rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: .02em;
}
.te-act-podium-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}
.te-act-podium-count {
    font-size: .7rem;
    font-weight: 700;
    padding: .1rem .42rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--text);
}
.te-act-podium-foot {
    margin-top: .15rem;
    font-size: .62rem;
    color: var(--text-muted);
    text-align: right;
    font-style: italic;
}
.te-act-empty {
    font-size: .82rem;
    color: var(--text-muted);
    padding: .35rem 0;
}

.te-act-expand-hint {
    position: absolute;
    bottom: .35rem;
    right: .55rem;
    font-size: .7rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}
.te-activity-banner:hover .te-act-expand-hint { opacity: .55; }

.te-act-recompute-btn {
    position: absolute;
    bottom: .4rem;
    right: 1.6rem;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .15rem .45rem;
    font-size: .68rem;
    font-family: inherit;
    line-height: 1.4;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
    border-radius: .25rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s, color .15s, border-color .15s, background .15s;
    z-index: 2;
}
.te-activity-banner:hover .te-act-recompute-btn,
.te-activity-banner:focus-within .te-act-recompute-btn { opacity: 1; }
.te-act-recompute-btn:hover {
    color: var(--text);
    border-color: color-mix(in srgb, var(--border) 80%, transparent);
    background: color-mix(in srgb, var(--text-muted) 10%, transparent);
}
.te-act-recompute-btn.is-confirm {
    color: var(--warning, #e8a000);
    border-color: color-mix(in srgb, var(--warning, #e8a000) 50%, transparent);
    opacity: 1;
}
.te-act-recompute-btn.is-done {
    color: var(--success, #3fb950);
    border-color: color-mix(in srgb, var(--success, #3fb950) 40%, transparent);
    opacity: 1;
    cursor: default;
}
.te-act-recompute-btn:disabled { pointer-events: none; }

@media (max-width: 1100px) {
    .te-activity-banner {
        grid-template-columns: minmax(140px, .8fr) 1fr 1fr;
    }
    .te-act-zone--spark { display: none; }
    .te-act-zone--podium { grid-column: span 3; }
    .te-act-zone--identity { grid-column: 1 / 2; grid-row: 1; }
}
@media (max-width: 768px) {
    .te-activity-banner {
        grid-template-columns: minmax(140px, .9fr) 1fr;
        padding: .8rem 1rem;
    }
    .te-act-zone--podium { grid-column: span 2; }
    .te-act-title { font-size: 1.2rem; }
    .te-act-title-icon { width: 1.65rem; height: 1.65rem; font-size: .95rem; }
    /* Picker stays anchored top-right; nudge inward so it doesn't kiss the corner */
    .te-act-window-picker { right: .65rem; }
}
@media (max-width: 576px) {
    .te-activity-banner {
        grid-template-columns: 1fr;
        padding: .85rem .9rem 1rem;
    }
    .te-act-zone--identity,
    .te-act-zone--stats,
    .te-act-zone--podium { grid-column: span 1; }
    .te-act-zone--identity { padding-bottom: .35rem; }
    .te-activity-banner > .te-act-zone + .te-act-zone {
        border-left: 0;
        border-top: 1px solid color-mix(in srgb, var(--border) 35%, transparent);
        padding-top: .55rem;
        margin-top: .35rem;
    }
    /* On very narrow screens, anchor the picker to the top-right corner cleanly */
    .te-act-window-picker {
        right: .55rem;
        top: .65rem;
        transform: none;
    }
    .te-act-title { font-size: 1.15rem; padding-right: 2.5rem; }
}

/* -- Activity modal ------------------------------------------------------- */
.te-actm-pills {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.te-actm-pill {
    padding: .25rem .7rem;
    background: color-mix(in srgb, var(--bg-card) 70%, transparent);
    border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .15s;
}
.te-actm-pill:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.te-actm-pill.is-active {
    background: color-mix(in srgb, var(--accent) 22%, transparent);
    border-color: var(--accent);
    color: var(--text);
}
.te-actm-pills-spacer { flex: 1; }
.te-actm-window-note {
    font-size: .72rem;
    color: var(--text-muted);
    font-style: italic;
}
.te-actm-section {
    margin-bottom: 1.25rem;
}
.te-actm-section-head {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .4rem;
}
.te-actm-section-head i { color: var(--accent); }
.te-actm-spark {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 90px;
    padding: .25rem .15rem;
    background: color-mix(in srgb, var(--bg-base) 50%, transparent);
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--border) 30%, transparent);
}
.te-actm-spark .te-act-spark-bar { min-height: 3px; }

.te-actm-leaderboard {
    background: color-mix(in srgb, var(--bg-base) 40%, transparent);
    border: 1px solid color-mix(in srgb, var(--border) 30%, transparent);
    border-radius: 8px;
    overflow: hidden;
}
.te-actm-lb-row {
    display: grid;
    grid-template-columns: 2.5rem 30px 1fr repeat(3, 60px) 70px;
    align-items: center;
    gap: .5rem;
    padding: .45rem .75rem;
    font-size: .85rem;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 25%, transparent);
}
.te-actm-lb-row:last-child { border-bottom: 0; }
.te-actm-lb-row.is-head {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--bg-base) 70%, transparent);
}
.te-actm-lb-row.is-me {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    box-shadow: inset 3px 0 0 var(--accent);
}
.te-actm-lb-rank { font-weight: 700; color: var(--text-muted); }
.te-actm-lb-row--rank-1 .te-actm-lb-rank { color: color-mix(in srgb, var(--text), gold 35%); }
.te-actm-lb-row--rank-2 .te-actm-lb-rank { color: color-mix(in srgb, var(--text), silver 30%); }
.te-actm-lb-row--rank-3 .te-actm-lb-rank { color: color-mix(in srgb, var(--text), #cd7f32 40%); }
.te-actm-lb-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.te-actm-lb-num { text-align: right; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.te-actm-lb-num.is-zero { opacity: .35; }
.te-actm-lb-total {
    text-align: right;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.te-actm-privacy-note {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin: 0 0 .55rem;
    padding: .4rem .65rem;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    border-radius: 8px;
    font-size: .72rem;
    color: var(--text-secondary);
}
.te-actm-privacy-note i { color: var(--accent); }

.te-actm-recent {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    padding: .35rem 0;
}
.te-actm-recent-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .2rem .55rem;
    background: color-mix(in srgb, var(--bg-card) 70%, transparent);
    border: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
    border-radius: 999px;
    font-size: .78rem;
    color: var(--text);
    text-decoration: none;
    transition: border-color .15s, transform .15s;
}
.te-actm-recent-chip:hover {
    border-color: color-mix(in srgb, var(--accent) 55%, transparent);
    transform: translateY(-1px);
    color: var(--text);
}
.te-actm-recent-chip-time {
    font-size: .65rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .te-actm-lb-row {
        grid-template-columns: 2rem 28px 1fr 50px 60px;
    }
    .te-actm-lb-row .te-actm-lb-num--created,
    .te-actm-lb-row .te-actm-lb-num--published { display: none; }
}

/* ============================================================
   Neutral variant (used on /tags � no accent colour)
   ============================================================ */
.te-activity-banner--neutral:hover { border-color: rgba(255,255,255,.12); box-shadow: 0 24px 70px rgba(0,0,0,.22); }
.te-activity-banner--neutral .te-act-stat i,
.te-activity-banner--neutral .te-act-podium-head i,
.te-activity-banner--neutral .te-act-stat--submitters i,
.te-activity-banner--neutral .te-act-stat--edited i,
.te-activity-banner--neutral .te-act-stat--created i { color: var(--text-muted); }
.te-activity-banner--neutral .te-act-spark-bar {
    background: linear-gradient(to top,
        color-mix(in srgb, var(--text-muted) 25%, transparent),
        color-mix(in srgb, var(--text-muted) 60%, transparent));
}
.te-activity-banner--neutral .te-act-podium-count {
    background: color-mix(in srgb, var(--text-muted) 18%, transparent);
    color: var(--text);
}
.te-activity-banner--neutral .te-act-podium-row.is-me {
    background: color-mix(in srgb, var(--text-muted) 10%, transparent);
    box-shadow: inset 3px 0 0 color-mix(in srgb, var(--text-muted) 60%, transparent);
}
.te-activity-banner--neutral .te-act-window-trigger:hover { color: var(--text); }
.te-activity-banner--neutral .te-act-window-opt.is-active { color: var(--text); background: color-mix(in srgb, var(--text-muted) 18%, transparent); }
.te-activity-banner--neutral .te-act-expand-hint { color: var(--text-muted); }

/* Recent-tag chip actor inline (cap holders only) */
.te-actm-recent-chip-actor {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    margin-left: .25rem;
    padding-left: .35rem;
    border-left: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
    font-size: .68rem;
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, monospace;
}
.te-actm-recent-chip-actor img {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    object-fit: cover;
}
