@font-face {
    font-family: Archivo;
    src: url('fonts/Archivo-Medium.woff2') format('woff2'),
    url('fonts/Archivo-Medium.woff') format('woff');
    font-weight: 500;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: Archivo;
    src: url('fonts/Archivo-SemiBold.woff2') format('woff2'),
    url('fonts/Archivo-SemiBold.woff') format('woff');
    font-weight: 600;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: Archivo;
    src: url('fonts/Archivo-ExtraBold.woff2') format('woff2'),
    url('fonts/Archivo-ExtraBold.woff') format('woff');
    font-weight: 900;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: Archivo;
    src: url('fonts/Archivo-Bold.woff2') format('woff2'),
    url('fonts/Archivo-Bold.woff') format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: Archivo;
    src: url('fonts/Archivo-Regular.woff2') format('woff2'),
    url('fonts/Archivo-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --header-background: rgba(255,255,255,0.9);

    --background: #ffffff;
    --foreground: #0a0a0a;
    --card: #ffffff;
    --card-foreground: #0a0a0a;
    --muted: #f5f5f5;
    --muted-foreground: #737373;
    --border: #e5e5e5;
    --input: #e5e5e5;
    --ring: #0a0a0a;

    --success: #22c55e;
    --success-foreground: #ffffff;
    --success-muted: #dcfce7;

    --destructive: #ef4444;
    --destructive-foreground: #ffffff;
    --destructive-muted: #fee2e2;

    --warning: #f59e0b;
    --warning-foreground: #ffffff;
    --warning-muted: #fef3c7;

    --override: #8b5cf6;
    --override-foreground: #ffffff;
    --override-muted: #ede9fe;

    --radius: 0.5rem;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

    --btn-filter: invert(0);
}

[data-theme="dark"] {
    --header-background: rgba(23,23,23,0.9);

    --background: #0a0a0a;
    --foreground: #fafafa;
    --card: #171717;
    --card-foreground: #fafafa;
    --muted: #262626;
    --muted-foreground: #a3a3a3;
    --border: #262626;
    --input: #262626;
    --ring: #d4d4d4;

    --success: #22c55e;
    --success-foreground: #ffffff;
    --success-muted: #14532d;

    --destructive: #ef4444;
    --destructive-foreground: #ffffff;
    --destructive-muted: #7f1d1d;

    --warning: #f59e0b;
    --warning-foreground: #ffffff;
    --warning-muted: #78350f;

    --override: #8b5cf6;
    --override-foreground: #ffffff;
    --override-muted: #4c1d95;
    --btn-filter: invert(1);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --header-background: rgba(23,23,23,0.9);
        --background: #0a0a0a;
        --foreground: #fafafa;
        --card: #171717;
        --card-foreground: #fafafa;
        --muted: #262626;
        --muted-foreground: #a3a3a3;
        --border: #262626;
        --input: #262626;
        --ring: #d4d4d4;

        --success: #22c55e;
        --success-foreground: #ffffff;
        --success-muted: #14532d;

        --destructive: #ef4444;
        --destructive-foreground: #ffffff;
        --destructive-muted: #7f1d1d;

        --warning: #f59e0b;
        --warning-foreground: #ffffff;
        --warning-muted: #78350f;

        --override: #8b5cf6;
        --override-foreground: #ffffff;
        --override-muted: #4c1d95;
        --btn-filter: invert(1);
    }
}

.sync-btn, .header-action button img {
    filter: var(--btn-filter);
}


html,
body {
    margin: 0;
    padding: 0;
    font-family: Archivo;
    background: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Header */
header {
    border-bottom: 1px solid var(--border);
    background: var(--header-background);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.overleash {
    gap: 1rem;
    display: flex;
    align-items: center;

    div {
        font-weight: 500;
        color: var(--foreground);
    }
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.header .logo {
    height: 28px;
    width: auto;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-action {
    display: flex;
    align-items: center;
}

.header-action .separator {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 0.25rem;
}

.theme-btn,
.search-btn {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.theme-btn:hover,
.search-btn:hover {
    background: var(--muted);
}

.theme-btn img,
.search-btn img {
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

/* Theme button states */
[data-theme="light"] .theme-btn .dark,
[data-theme="light"] .theme-btn .auto,
[data-theme="dark"] .theme-btn .light,
[data-theme="dark"] .theme-btn .auto {
    display: none;
}

[data-theme="auto"] .theme-btn .light,
[data-theme="auto"] .theme-btn .dark {
    display: none;
}

/* Heading / Toolbar */
.heading {
    border-bottom: 1px solid var(--border);
    background: var(--card);
    padding: 1rem 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sync {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

#last-sync strong {
    color: var(--foreground);
}

.sync-btn {
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;

    img {
        animation-name: spin;
        animation-iteration-count: infinite;
        animation-duration: 2s;
        animation-timing-function: linear;
        animation-play-state: paused;
    }

    &:hover img {
        animation-play-state: running;
    }
}

.sync-btn:hover {
}

.sync-btn img {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

/* Search */
.search-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search {
    flex: 1;
    width: 100%;
}

.search .input {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--foreground);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search .input::placeholder {
    color: var(--muted-foreground);
}

.search .input:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .search .input:focus {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.05);
}

/* Feature Filter Dropdowns */
.feature-filter {
    display: flex;
    gap: 0.5rem;
}

.select-menu {
    position: relative;
}

.select-menu summary {
    list-style: none;
    cursor: pointer;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.15s;
    white-space: nowrap;
}

.select-menu summary::-webkit-details-marker {
    display: none;
}

.select-menu summary:hover {
    background: var(--muted);
}

.select-menu summary .way {
    color: var(--muted-foreground);
}

.dropdown-caret {
    border: 4px solid transparent;
    border-top-color: currentColor;
    margin-left: 0.25rem;
    display: inline-block;
    vertical-align: middle;
    margin-top: 2px;
}

.select-menu article {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 100;
}

.select-menu-modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    overflow: hidden;
}

.select-menu-list {
    display: flex;
    flex-direction: column;
}

.select-menu-item {
    padding: 0.625rem 1rem;
    text-decoration: none;
    color: var(--foreground);
    font-size: 0.875rem;
    transition: background 0.15s;
    cursor: pointer;
}

.select-menu-item:hover {
    background: var(--muted);
}

.select-menu-item.select-menu-selected {
    background: var(--muted);
    font-weight: 500;
}

/* Remote Selector */
.remote-select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--foreground);
    font-size: 0.875rem;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.remote-select:hover {
    background-color: var(--muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
    white-space: nowrap;
}

.btn.small {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
}

.btn.black {
    background: var(--foreground);
    color: var(--background);
    border-color: var(--foreground);
}

.btn.black:hover {
    opacity: 0.85;
}

.btn.white {
    background: var(--card);
    color: var(--foreground);
    border-color: var(--border);
}

.btn.white:hover {
    background: var(--muted);
}

.btn.success {
    background: var(--success);
    color: var(--success-foreground);
    border-color: var(--success);
}

.btn.success:hover {
    opacity: 0.9;
}

.btn.destructive {
    background: var(--destructive);
    color: var(--destructive-foreground);
    border-color: var(--destructive);
}

.btn.destructive:hover {
    opacity: 0.9;
}

.shortcuts {
    display: none;
    opacity: 0.5;
    font-size: 0.75rem;
}

.selected .shortcuts {
    display: inline;
}

/* Features List */
.features {
    padding: 1.5rem 0;
}

.feature-bar {
    margin-bottom: 1rem;
}

.feature-count {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.feature-count strong {
    color: var(--foreground);
}

.feature-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Flag Card */
.card.flag {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.15s;
}

.card.flag.selected {
    border-color: var(--ring);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .card.flag.selected {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.05);
}

/* Flag has override - add left border indicator */
.card.flag:has(.override.enabled) {
    border-left: 3px solid var(--success);
}

.card.flag:has(.override.disabled) {
    border-left: 3px solid var(--destructive);
}

.card.flag:has(.override.paused) {
    border-left: 3px solid var(--warning);
}

.flag-name {
    padding: 1rem 1rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.flag-name .key {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--foreground);
}

.flag-name .key mark {
    background: var(--warning-muted);
    color: var(--foreground);
    padding: 0 2px;
    border-radius: 2px;
}

.stale-status {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    background: var(--warning-muted);
    color: var(--warning);
    border-radius: 9999px;
    font-weight: 500;
}

.description {
    padding: 0 1rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

.description a {
    color: var(--override);
    text-decoration: underline;
}

.separator {
    height: 1px;
    background: var(--border);
    margin: 0;
}

/* Current Status */
.current-status {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.current-status > div {
    font-size: 0.8125rem;
}

.current-status .label {
    color: var(--muted-foreground);
}

.current-status .text {
    font-weight: 500;
    color: var(--foreground);
}

/* Strategy Summaries in collapsed view */
.strategy-summary {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

.strategy-summary strong {
    color: var(--foreground);
    font-weight: 600;
}

.strategy-summary .constraint-tag {
    color: var(--override);
    font-weight: 500;
}

.strategy-summary .segment-tag {
    color: var(--success);
    font-weight: 500;
}

/* Actions */
.action {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action .list {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border);
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.action .list::before {
    content: "";
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--foreground);
    transition: transform 0.15s;
}

.action .list:hover {
    background: var(--muted);
}

.action .list.muted::before {
    transform: rotate(180deg);
}

/* Override Banner */
.override {
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.875rem;
    font-weight: 500;
}

.override.enabled {
    background: var(--success-muted);
    border-top: 1px solid var(--success);
}

.override.enabled .status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: var(--success);
    color: var(--success-foreground);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.override.disabled {
    background: var(--destructive-muted);
    border-top: 1px solid var(--destructive);
}

.override.disabled .status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: var(--destructive);
    color: var(--destructive-foreground);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.override.paused {
    background: var(--warning-muted);
    border-top: 1px solid var(--warning);
}

.override.paused .status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: var(--warning);
    color: var(--warning-foreground);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.override > div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.override .btn {
    background: var(--card);
    border-color: var(--border);
}

.override.enabled .btn:hover {
    background: var(--success);
    color: var(--success-foreground);
    border-color: var(--success);
}

.override.disabled .btn:hover {
    background: var(--destructive);
    color: var(--destructive-foreground);
    border-color: var(--destructive);
}

/* Detail View / Expanded */
.detail-environment {
    margin-top: 1rem;
}

.detail-environment-separator {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.detail-environment h4 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--foreground);

    &.active {
        font-weight: 800;
    }
}

/* Segments display */
.segment-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: var(--override-muted);
    color: var(--override);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Empty State */
.empty-state {
    padding: 3rem;
    text-align: center;
    color: var(--muted-foreground);
    font-size: 0.9375rem;
}

.empty-state strong {
    color: var(--foreground);
}

.striped-card {
    background: repeating-linear-gradient(-45deg, var(--muted), var(--muted) 10px, var(--card) 10px, var(--card) 20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Help Dialog */
#help-dialog {
    border: none;
    border-radius: var(--radius);
    background: var(--card);
    color: var(--foreground);
    padding: 0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 500px;
    width: 90vw;
}

#help-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.help {
    padding: 1.5rem;
}

.kbd-shortcuts {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.kbd-shortcut {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.kbd-shortcut .keys {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.kbd-shortcut .action {
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.5rem;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    min-width: 28px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.version {
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-bottom: 1rem;
}

/* Keyboard Hints Bar */
.keyboard-hints {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 0.5rem 1rem;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.keyboard-hints .hint {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.keyboard-hints kbd {
    padding: 0.125rem 0.375rem;
    min-width: 20px;
    font-size: 0.6875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .container {
        padding: 0 1rem;
    }

    .head {
        flex-direction: column;
        align-items: flex-start;
    }

    .sync {
        width: 100%;
        justify-content: space-between;
    }

    .search-container {
        flex-direction: column;
    }

    .feature-filter {
        width: 100%;
        justify-content: flex-end;
    }

    .override {
        flex-direction: column;
        align-items: flex-start;
    }

    .keyboard-hints {
        display: none;
    }
}

.detail-container {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    align-items: stretch;
    flex-direction: column;

    .type {
        color: var(--muted-foreground);
        font-weight: bold;
    }
}

.strategy {
    border-radius: 6px;
    background: var(--muted);

    .title {
        font-weight: 700;
        padding: 0.5rem 0.5rem 0;;
        color: var(--foreground);

        .text {
            font-weight: 500;
        }
    }
}

.constraint {
    position: relative;
    margin: 8px;
    display: flex;
    gap: 1rem;
    color: var(--muted-foreground);
    padding: 12px 16px;
    border: 1px solid rgb(225 225 227);
    border-radius: 8px;
    box-shadow: none;
    align-items: center;

    .name {
        color: var(--foreground);
        font-weight: 500;
        overflow: hidden;
        word-break: break-word;
        font-size: 0.875rem;
        flex-shrink: 0;
    }

    .inverted strong {
        background: var(--destructive-muted);
        color: var(--destructive);
        padding: 0.125rem 0.375rem;
        border-radius: 4px;
        font-size: 0.6875rem;
        margin-left: 0.25rem;
    }

    .operator {
        display: flex;
        margin: auto 0;
        min-width: 100px;
        position: relative;
        padding: 4px 12px;
        border-radius: 4px;
        background: var(--card);
        line-height: 1.25;
        font-size: 0.875rem;
        color: var(--foreground);
        justify-content: center;
    }

    .values {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        word-break: break-word;
        font-size: 0.875rem;
        margin: auto 0;
        color: var(--override);
    }

    .constrain-separator {
        position: absolute;
        padding: 6px 8px;
        bottom: -18px;
        left: 1rem;
        background-color: var(--background);
        color: var(--muted-foreground);
        z-index: 100;
        text-transform: uppercase;
        border-radius: 0.5rem;
        font-size: 0.75rem;
    }
}

@keyframes spin {
    100% {
        transform: rotate(-1turn);
    }
}

.verdict {
    color: var(--foreground);

    span {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 5px 8px;
        border-radius: 4px;
        font-size: 0.75rem;
        font-weight: 700;
        line-height: 1;
    }
}