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

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;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    padding: 2rem 1rem;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 300;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    min-height: calc(100vh - 200px);
}

.input-section, .output-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.regex-section, .text-section {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #495057;
}

textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    resize: vertical;
    transition: border-color 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#regex-input {
    background: #fff;
    font-weight: 500;
}

#text-input {
    background: #fff;
    line-height: 1.5;
}

.flags-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

.flags {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
}

.flags label {
    font-weight: normal;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.flags input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.error-section {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 8px;
    padding: 1rem;
}

.error-section h3 {
    color: #c53030;
    margin-bottom: 0.5rem;
}

#error-output {
    color: #e53e3e;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    background: white;
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid #fed7d7;
}

.matches-section, .highlighted-text-section, .capture-groups-section {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.matches-section h3, .highlighted-text-section h3, .capture-groups-section h3 {
    color: #495057;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

#match-count {
    font-weight: normal;
    color: #6c757d;
    font-size: 0.9rem;
}

#matches-output, #capture-groups-output {
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 1rem;
}

.match-item {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #e3f2fd;
    border-radius: 4px;
    border-left: 4px solid #2196f3;
}

.match-item:last-child {
    margin-bottom: 0;
}

.match-text {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-weight: 600;
    color: #1976d2;
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.match-info {
    font-size: 0.85rem;
    color: #666;
}

.capture-group {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: #f1f8e9;
    border-radius: 4px;
    border-left: 4px solid #8bc34a;
}

.capture-group:last-child {
    margin-bottom: 0;
}

.capture-label {
    font-weight: 600;
    color: #689f38;
    font-size: 0.9rem;
}

.capture-text {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    margin-top: 0.25rem;
    display: inline-block;
}

.capture-info {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
}

#highlighted-text {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
}

.highlight-match {
    background: #ffeb3b;
    color: #333;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
}

.highlight-group-1 { background: #e3f2fd; }
.highlight-group-2 { background: #f3e5f5; }
.highlight-group-3 { background: #e8f5e8; }
.highlight-group-4 { background: #fff3e0; }
.highlight-group-5 { background: #fce4ec; }

.no-matches, .no-captures {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 2rem;
}

footer {
    background: #495057;
    color: white;
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
}

footer a {
    color: #adb5bd;
    text-decoration: none;
}

footer a:hover {
    color: white;
    text-decoration: underline;
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .flags {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .container {
        margin: 0;
        box-shadow: none;
    }
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Animation for new matches */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.match-item, .capture-group {
    animation: fadeIn 0.3s ease-out;
}