:root {
    --primary: #10B981;
    --primary-hover: #059669;
    --accent: #34D399;
    --match-bg: rgba(16, 185, 129, 0.2);
    --match-border: rgba(16, 185, 129, 0.5);
    --bg: #0F172A;
    --bg-panel: rgba(15, 23, 42, 0.88);
    --border: rgba(255, 255, 255, 0.07);
    --text: #F1F5F9;
    --text-muted: #94A3B8;
    --error: #EF4444;
    --radius: 12px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    background: radial-gradient(circle at top left, rgba(16, 185, 129, 0.06), transparent 50%),
        radial-gradient(circle at bottom right, rgba(52, 211, 153, 0.04), transparent 50%),
        var(--bg);
}

.app {
    width: 100%;
    max-width: 1200px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    padding: 1.25rem;
}

header {
    text-align: center;
}

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

.subtitle {
    color: var(--text-muted);
    margin-top: 0.2rem;
    font-size: 0.9rem;
}

h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.25rem;
}

.right-col {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Regex Input */
.regex-row {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.4rem;
    margin-bottom: 0.75rem;
}

.regex-delim {
    color: var(--primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    padding: 0 0.3rem;
}

.regex-row input[type="text"] {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    padding: 0.3rem;
}

.regex-row input[type="text"]:focus {
    outline: none;
}

.regex-row input[type="text"]:last-of-type {
    width: 50px;
    flex: none;
    color: var(--text-muted);
}

.error-msg {
    color: var(--error);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.hidden {
    display: none !important;
}

.field-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    display: block;
}

textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    resize: vertical;
    transition: var(--transition);
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.match-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0.4rem 0;
}

/* Highlight output */
.highlight-output {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 3rem;
    max-height: 200px;
    overflow-y: auto;
}

.highlight-output mark {
    background: var(--match-bg);
    border: 1px solid var(--match-border);
    border-radius: 3px;
    padding: 0 2px;
    color: var(--accent);
}

/* Quick actions */
.quick-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.75rem;
    align-items: center;
}

select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
}

.btn-sm:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Explanation */
.explain-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.explain-item {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.35rem 0.5rem;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    font-size: 0.8rem;
}

.explain-token {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent);
    font-weight: 500;
    white-space: nowrap;
}

.explain-desc {
    color: var(--text-muted);
}

.muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Cheatsheet */
.cheat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.3rem;
}

.cheat-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.78rem;
    padding: 0.25rem 0.4rem;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.cheat-item code {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent);
    background: rgba(16, 185, 129, 0.1);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.75rem;
}

.cheat-item span {
    color: var(--text-muted);
}

footer {
    padding: 1rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }
}