.unicorn-tabs-wrapper {
    margin: 20px 0;
}

/* Editor sidebar only (Manage Tabs panel) - never printed to the frontend.
   One flat row per tab: grip, title, delete - no card, no wrapping box. */
.unicorn-tabs-manage-row {
    display: flex;
    align-items: center;
    gap: 2px;
    cursor: grab;
}
.unicorn-tabs-manage-row + .unicorn-tabs-manage-row {
    margin-top: 4px;
}
.unicorn-tabs-manage-row-grip {
    cursor: grab;
    flex: 0 0 auto;
}
.unicorn-tabs-manage-row-title {
    flex: 1;
    min-width: 0;
}

/* Editor sidebar only (Settings panel) - the Design picker. */
.unicorn-tabs-designs {
    display: grid;
    grid-template-columns: repeat( 3, 1fr );
    gap: 8px;
    margin-bottom: 16px;
}
.unicorn-tabs-design-option {
    position: relative;
    display: grid;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--border-stroke);
    border-radius: 6px;
    cursor: pointer;
}
.unicorn-tabs-design-option:has( input:checked ) {
    border-color: var(--surfaces-primary);
    box-shadow: 0 0 0 1px var(--surfaces-primary);
}
.unicorn-tabs-design-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.unicorn-tabs-design-name {
    font-size: var(--text-xxs);
    font-weight: var(--cc-font-weight-bold);
    text-transform: uppercase;
    text-align: center;
}
.unicorn-tabs-design-preview {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    padding: 4px 4px 0;
    border-bottom: 1px solid var(--border-stroke);
}
.unicorn-tabs-design-chip {
    flex: 1;
    height: 10px;
    background: color-mix( in srgb, currentColor 12%, transparent );
}
.unicorn-tabs-design-chip.is-active {
    background: var(--surfaces-primary);
}
.unicorn-tabs-design-preview--line .unicorn-tabs-design-chip {
    border-radius: 2px 2px 0 0;
    height: 8px;
}
.unicorn-tabs-design-preview--line .unicorn-tabs-design-chip.is-active {
    height: 10px;
    background: transparent;
    border-bottom: 2px solid var(--surfaces-primary);
}
.unicorn-tabs-design-preview--pill {
    border-bottom: none;
    padding-bottom: 4px;
}
.unicorn-tabs-design-preview--pill .unicorn-tabs-design-chip {
    border-radius: 999px;
}
.unicorn-tabs-design-preview--rounded .unicorn-tabs-design-chip {
    border-radius: 3px 3px 0 0;
}

.unicorn-tabs-tabbar {
    display: flex;
    align-items: center;
    gap: 4px;
    border-bottom: 1px solid var(--border-stroke);
}

.unicorn-tabs-align-center .unicorn-tabs-tabbar {
    justify-content: center;
}

.unicorn-tabs-align-right .unicorn-tabs-tabbar {
    justify-content: flex-end;
}

.unicorn-tabs-tab {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 12px 18px;
    color: var(--text-secondary); /* deliberate: an inactive tab has no fill of its own, so its colour is semantic, not derived */
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.unicorn-tabs-tab:hover {
    --bgColor: color-mix( in srgb, var(--accent) 6%, var(--surfaces-background) );
    color: var(--text-primary);
    background-color: var(--bgColor);
}
@supports ( color: contrast-color( red ) ) {
    .unicorn-tabs-tab:hover {
        color: contrast-color( var(--bgColor) );
    }
}

/* Line (default): as-is - an underline marks the active tab, no fill. */
.unicorn-tabs-design-line .unicorn-tabs-tab {
    border-bottom: 2px solid transparent;
    border-radius: 6px 6px 0 0;
}
.unicorn-tabs-design-line .unicorn-tabs-tab.is-active {
    color: var(--text-primary);
    border-bottom-color: var(--accent, var(--surfaces-primary));
}

/* Pill: fully rounded, the active tab fills solid. */
.unicorn-tabs-design-pill .unicorn-tabs-tabbar {
    border-bottom: none;
}
.unicorn-tabs-design-pill .unicorn-tabs-tab {
    border-radius: 999px;
}
.unicorn-tabs-design-pill .unicorn-tabs-tab.is-active {
    background-color: var(--accent, var(--surfaces-primary));
    color: var(--text-primary);
}
@supports ( color: contrast-color( red ) ) {
    .unicorn-tabs-design-pill .unicorn-tabs-tab.is-active {
        color: contrast-color( var(--accent, var(--surfaces-primary)) );
    }
}

/* Rounded: top corners only, the active tab sits flush on the divider like a
   folder tab - the usual browser-tab shape. */
.unicorn-tabs-design-rounded .unicorn-tabs-tab {
    border-radius: 8px 8px 0 0;
    margin-bottom: -1px;
}
.unicorn-tabs-design-rounded .unicorn-tabs-tab.is-active {
    background-color: var(--accent, var(--surfaces-primary));
    color: var(--text-primary);
    border: 1px solid var(--accent, var(--surfaces-primary));
    border-bottom-color: var(--accent, var(--surfaces-primary));
}
@supports ( color: contrast-color( red ) ) {
    .unicorn-tabs-design-rounded .unicorn-tabs-tab.is-active {
        color: contrast-color( var(--accent, var(--surfaces-primary)) );
    }
}

.unicorn-tabs-panel {
    display: none;
    padding: 24px 0;
}

.unicorn-tabs-panel.is-active {
    display: block;
    animation: unicorn-tabs-fade 0.2s ease;
}

@keyframes unicorn-tabs-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Swipe: the tab bar scrolls horizontally instead of wrapping. tabAlign is
   moot once tabs overflow, so the row always starts flush left. */
@media ( max-width: 720px ) {
    .unicorn-tabs-mobile-swipe .unicorn-tabs-tabbar {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .unicorn-tabs-mobile-swipe .unicorn-tabs-tabbar::-webkit-scrollbar {
        display: none;
    }
    .unicorn-tabs-mobile-swipe .unicorn-tabs-tab {
        flex: 0 0 auto;
    }

    /* Dropdown: only the active tab shows, as a closed trigger with a chevron.
       Clicking it (frontend.js) toggles .is-expanded, which drops the rest of
       the tabs down as a stacked list. */
    .unicorn-tabs-mobile-dropdown .unicorn-tabs-tabbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        border-bottom: none;
        border: 1px solid var(--border-stroke);
        border-radius: var(--block-radius, 16px);
        overflow: hidden; /* clip a tab's own border/radius (e.g. the rounded design) to this container's corners */
    }
    .unicorn-tabs-mobile-dropdown .unicorn-tabs-tab {
        display: none;
        width: 100%;
        justify-content: space-between;
        text-align: left;
        border-radius: 0;
        border-bottom: 1px solid var(--border-stroke);
    }
    /* The desktop rounded design's folder-tab geometry (a border on every side,
       a negative margin to overlap the shared divider) has nothing to overlap
       once the bar collapses to this bordered, rounded-container trigger -
       left unreset, that border's top/left/right edges poke out past the
       container's own corner (no shared radius to clip to), showing as a
       stray sliver. Chained to match the rounded rule's own specificity so
       this always wins regardless of source order. Swipe mode keeps a plain
       divider row like the desktop layout, so it needs no equivalent reset. */
    .unicorn-tabs-design-rounded.unicorn-tabs-mobile-dropdown .unicorn-tabs-tab {
        margin-bottom: 0;
        border: none;
    }
    .unicorn-tabs-mobile-dropdown .unicorn-tabs-tab:last-child {
        border-bottom: none;
    }
    .unicorn-tabs-mobile-dropdown .unicorn-tabs-tab.is-active {
        display: flex;
        align-items: center;
        border-bottom: none;
    }
    .unicorn-tabs-mobile-dropdown .unicorn-tabs-tab.is-active::after {
        content: '';
        width: 8px;
        height: 8px;
        margin-left: 12px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate( 45deg );
        transition: transform 0.15s ease;
        flex-shrink: 0;
    }
    .unicorn-tabs-mobile-dropdown .unicorn-tabs-tabbar.is-expanded .unicorn-tabs-tab {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .unicorn-tabs-mobile-dropdown .unicorn-tabs-tabbar.is-expanded .unicorn-tabs-tab:last-child {
        border-bottom: none;
    }
    /* Expanded: which tab is open cannot depend on spotting a thin border in a
       list of identical-looking rows - the active one pins to the top (flexbox
       `order`, DOM order is untouched so keyboard nav still walks in tab order)
       and swaps its chevron for a checkmark. */
    .unicorn-tabs-mobile-dropdown .unicorn-tabs-tabbar.is-expanded .unicorn-tabs-tab.is-active {
        order: -1;
        border-bottom: 1px solid var(--border-stroke);
        background-color: color-mix( in srgb, var(--accent) 8%, transparent );
        font-weight: var(--cc-font-weight-bold);
    }
    .unicorn-tabs-mobile-dropdown .unicorn-tabs-tabbar.is-expanded .unicorn-tabs-tab.is-active:last-child {
        border-bottom: 1px solid var(--border-stroke);
    }
    .unicorn-tabs-mobile-dropdown .unicorn-tabs-tabbar.is-expanded .unicorn-tabs-tab.is-active::after {
        content: '\2713';
        width: auto;
        height: auto;
        border: none;
        transform: none;
        color: var(--accent, var(--surfaces-primary)); /* deliberate: a checkmark on the light 8% tint below, not a fill needing contrast-color() */
    }
}
