:root {
    --font-sans: 'Inter', system-ui, sans-serif;
    --bg: #0F172A;
    --surface: rgba(30, 41, 59, .8);
    --surface-2: rgba(51, 65, 85, .5);
    --border: rgba(99, 102, 241, .1);
    --border-hover: rgba(99, 102, 241, .3);
    --primary: #6366F1;
    --accent: #22D3EE;
    --text: #E2E8F0;
    --text-muted: #94A3B8;
    --text-dim: #64748B;
    --green: #4ADE80;
    --red: #F87171;
    --radius: 12px;
    --radius-sm: 8px
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6
}

.header {
    padding: .7rem 2rem;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
    background: rgba(15, 23, 42, .85);
    position: sticky;
    top: 0;
    z-index: 50
}

.header-inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between
}

.logo {
    display: flex;
    align-items: center;
    gap: .5rem
}

.logo-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, .08);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem
}

.logo-text {
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.main {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem 2rem 3rem
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: .75rem;
    backdrop-filter: blur(12px)
}

.section-title {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: .5rem
}

.expression-card {
    text-align: center;
    padding: 1.25rem
}

.expression {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: .15em;
    font-family: 'JetBrains Mono', monospace
}

.natural {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: .3rem
}

.presets {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    margin-bottom: .75rem
}

.preset {
    padding: .25rem .5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: .68rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    font-family: var(--font-sans)
}

.preset:hover {
    border-color: var(--primary);
    color: var(--text)
}

.selectors-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
    margin-bottom: .75rem
}

.selector {
    padding: .7rem
}

.sel-title {
    font-size: .68rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: .3rem
}

.sel-mode {
    display: block;
    margin-bottom: .3rem;
    padding: .25rem .4rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: .7rem;
    outline: none
}

.sel-num {
    display: block;
    width: 60px;
    padding: .2rem .35rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: .75rem;
    outline: none
}

.sel-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .15rem
}

.sel-cell {
    width: 28px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .6rem;
    border-radius: 3px;
    cursor: pointer;
    background: var(--surface-2);
    border: 1px solid transparent;
    color: var(--text-dim);
    transition: all .1s;
    font-weight: 500
}

.sel-cell:hover {
    border-color: var(--primary)
}

.sel-cell.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary)
}

.validate-row {
    display: flex;
    gap: .4rem
}

.validate-input {
    flex: 1;
    padding: .35rem .5rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: .78rem;
    outline: none;
    font-family: monospace
}

.validate-result {
    margin-top: .4rem;
    padding: .3rem .5rem;
    border-radius: 6px;
    font-size: .72rem;
    font-weight: 600
}

.validate-pass {
    background: rgba(74, 222, 128, .06);
    border: 1px solid rgba(74, 222, 128, .15);
    color: var(--green)
}

.validate-fail {
    background: rgba(248, 113, 113, .06);
    border: 1px solid rgba(248, 113, 113, .15);
    color: var(--red)
}

.runs-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: .15rem
}

.runs-list li {
    padding: .25rem .5rem;
    background: var(--surface-2);
    border-radius: 4px;
    font-size: .72rem;
    font-family: monospace;
    display: flex;
    gap: .5rem
}

.runs-list li .run-idx {
    color: var(--primary);
    font-weight: 700;
    width: 18px
}

.runs-list li .run-date {
    color: var(--text)
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    border: none;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s
}

.btn--primary {
    background: var(--primary);
    color: #fff;
    padding: .4rem .65rem
}

.btn--accent {
    background: var(--accent);
    color: #0F172A;
    padding: .3rem .5rem
}

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
    padding: .3rem .5rem
}

.btn--ghost:hover {
    background: rgba(99, 102, 241, .06);
    color: var(--text)
}

.btn--sm {
    font-size: .7rem;
    padding: .25rem .4rem
}

.hidden {
    display: none !important
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: rgba(30, 41, 59, .95);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .5rem .85rem;
    border-radius: var(--radius-sm);
    font-size: .78rem;
    font-weight: 500;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .4);
    backdrop-filter: blur(12px);
    opacity: 0;
    pointer-events: none;
    transition: all .4s cubic-bezier(.16, 1, .3, 1);
    z-index: 100
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
}

@media(max-width:600px) {
    .header {
        padding: .7rem 1rem
    }

    .main {
        padding: 1rem
    }

    .selectors-grid {
        grid-template-columns: 1fr
    }
}