:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --primary-neon: #38bdf8;
    --secondary-neon: #818cf8;
    --success-neon: #4ade80;
    --error-neon: #f87171;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --color-strict: #7f1d1d;
    /* 深红 === */
    --color-loose: #ef4444;
    /* 红 == */
    --color-both: #f59e0b;
    /* 橙 >= && <= */
    --color-gte: #10b981;
    /* 绿 >= */
    --color-lte: #3b82f6;
    /* 蓝 <= */
    --color-none: #334155;
    /* 灰 else */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(129, 140, 248, 0.15) 0%, transparent 40%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 4rem;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(to right, var(--primary-neon), var(--secondary-neon));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -0.05em;
}

p.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.playground {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 3rem;
    border-radius: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-box {
    background: rgba(15, 23, 42, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-box:focus-within {
    border-color: var(--primary-neon);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
    transform: translateY(-2px);
}

input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    text-align: center;
}

.type-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    margin-top: 1rem;
}

.operator-switcher {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
}

/* Matrix Controls */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.matrix-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.4);
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.matrix-op-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.matrix-op-group {
    display: flex;
    gap: 0.2rem;
}

.m-op-btn {
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: none;
    border-radius: 0.4rem;
    color: var(--text-secondary);
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.m-op-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.m-op-btn.active {
    color: var(--primary-neon);
    background: rgba(56, 189, 248, 0.1);
}

.op-label {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

.operator-group {
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.4rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    position: relative;
}

.op-btn {
    padding: 0.6rem 1.25rem;
    background: transparent;
    border: none;
    border-radius: 1.5rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: ui-monospace, monospace;
    position: relative;
    z-index: 2;
}

.op-btn:hover {
    color: var(--text-primary);
}

.op-btn.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary-neon), var(--secondary-neon));
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.category-header {
    grid-column: 1 / -1;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--primary-neon);
    display: flex;
    align-items: center;
    gap: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.category-header::before {
    content: "";
    width: 4px;
    height: 18px;
    background: var(--primary-neon);
    border-radius: 2px;
}



.result-overlay {
    margin-top: 3rem;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.result-overlay.visible {
    opacity: 1;
    transform: translateY(0);
}

.result-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.result-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    min-width: 120px;
    text-align: right;
}

.result-card {
    padding: 0.75rem 2rem;
    border-radius: 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    min-width: 120px;
    text-align: center;
}

.result-card.true {
    background: rgba(74, 222, 128, 0.1);
    color: var(--success-neon);
    border: 1px solid var(--success-neon);
}

.result-card.false {
    background: rgba(248, 113, 113, 0.1);
    color: var(--error-neon);
    border: 1px solid var(--error-neon);
}

.explanation {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.pulse {
    animation: pulse 0.5s ease-in-out;
}

/* Responsive Design */
@media (max-width: 768px) {
    h1 {
        font-size: 2.2rem;
    }

    .playground {
        flex-direction: column;
        padding: 2rem;
        gap: 1rem;
    }

    .top-switcher {
        flex-direction: row !important;
        width: 100%;
        justify-content: center;
        gap: 1rem;
    }

    .top-switcher .operator-group {
        flex-direction: row !important;
        border-radius: 1rem;
    }

    .top-switcher .op-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .operator-switcher {
        margin: 1rem 0;
    }

    .input-group {
        width: 100%;
    }

    .result-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .result-label {
        min-width: auto;
        text-align: center;
    }

    .result-card {
        width: 100%;
        max-width: 200px;
    }

    .container {
        padding: 1rem;
    }
}

/* Palette Styles */
.palette-section {
    margin-top: 5rem;
    width: 100%;
}

.palette-section h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.palette-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.palette-chip {
    padding: 0.5rem 1rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    color: var(--text-primary);
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.palette-chip:hover {
    border-color: var(--primary-neon);
    background: rgba(56, 189, 248, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.1);
}

/* Explanation Hiding */
.explanation-container {
    margin-top: 1rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.explanation {
    color: var(--text-secondary);
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: default;
}

.result-overlay:hover .explanation {
    opacity: 1;
}

/* Matrix Table Styles */
.matrix-section {
    margin-top: 5rem;
    width: 100%;
}

.matrix-section h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.matrix-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 2rem;
    padding: 1.5rem;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.matrix-grid {
    display: grid;
    width: 100%;
    height: 100%;
}

.matrix-cell {
    border: 1px solid rgba(255, 255, 255, 0.15);
    /* Sharper borders */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background-color: var(--color-none);
    cursor: pointer;
    position: relative;
    font-size: 0.5rem;
}

.matrix-cell:not(.header):not(.header-col):not(.header-row):hover {
    filter: brightness(1.3);
    z-index: 10;
    transform: scale(1.4);
    border-radius: 4px;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
    border: 1px solid #fff;
}

.matrix-cell.true {
    background: var(--success-neon) !important;
}

.matrix-cell.false {
    background: var(--error-neon) !important;
    opacity: 0.35;
}

.matrix-cell.header {
    background: transparent;
    border: none;
}

.matrix-cell.header-col {
    background: transparent;
    border: none;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 2px;
}

.matrix-cell.header-row {
    background: transparent;
    border: none;
    text-align: right;
    justify-content: flex-end;
    padding-right: 8px;
    font-weight: 700;
    font-size: 0.6rem;
    color: var(--text-secondary);
}

/* Tooltip on hover */
.matrix-cell[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 0.3rem 0.6rem;
    border-radius: 0.4rem;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 100;
}

@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .matrix-op-group {
        flex-wrap: wrap;
        justify-content: center;
    }

    .matrix-container {
        padding: 0.5rem;
        border-radius: 1rem;
        aspect-ratio: auto;
        height: auto;
    }

    .matrix-grid {
        aspect-ratio: 1/1;
    }

    .matrix-cell.header-col,
    .matrix-cell.header-row {
        font-size: 0.35rem;
    }
}