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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    color: #fff;
    margin-bottom: 0.5rem;
}

header p {
    color: #fff;
}

.regex-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.input-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.regex-input {
    margin-bottom: 1.5rem;
}

.regex-input label {
    display: block;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-weight: 500;
}

.pattern-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pattern-delimiter {
    font-size: 1.5rem;
    color: #7f8c8d;
    user-select: none;
}

#pattern {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    font-size: 1rem;
}

#flags {
    width: 80px;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    font-size: 1rem;
    text-align: center;
}

input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.flags-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
}

.flag-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.flag-item label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    cursor: pointer;
}

.flag-desc {
    color: #666;
    font-size: 0.9rem;
    margin-left: 1.5rem;
}

.test-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.test-input {
    margin-bottom: 1.5rem;
}

.test-input label {
    display: block;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-weight: 500;
}

#testString {
    width: 100%;
    height: 150px;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    font-size: 1rem;
    resize: vertical;
}

.results-panel {
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}

.panel-header {
    padding: 1rem;
    background: #ecf0f1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#matchCount {
    color: #666;
    font-size: 0.9rem;
}

.secondary-btn {
    padding: 0.5rem 1rem;
    background: #fff;
    color: #2c3e50;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    background: #f1f1f1;
    border-color: #bdc3c7;
}

.results-content {
    padding: 1rem;
    font-family: monospace;
    font-size: 0.9rem;
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
}

.match {
    background: #a8e6cf;
    padding: 0.1em 0;
}

.group {
    background: #ffd3b6;
    padding: 0.1em 0;
}

.quick-reference {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.quick-reference h3 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
}

.reference-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.reference-group h4 {
    color: #2c3e50;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #ecf0f1;
}

.reference-item {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.reference-item code {
    font-family: monospace;
    background: #f8f9fa;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 60px;
}

.reference-item span {
    color: #666;
    font-size: 0.9rem;
}

footer {
    text-align: center;
    margin-top: 2rem;
    color: #666;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .regex-container {
        gap: 1rem;
    }

    .input-section,
    .test-section,
    .quick-reference {
        padding: 1rem;
    }

    .flags-info {
        grid-template-columns: 1fr;
    }

    .reference-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}