* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #3b82f6;
    --primary-dark: #1e40af;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace; background: #f5f7fa; color: var(--gray-900); }
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* Landing */
header {
    text-align: center;
    padding: 60px 20px 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: var(--radius);
    margin-bottom: 40px;
}
header h1 { font-size: 3em; margin-bottom: 10px; }
.hero, .features, .pricing, .examples {
    background: white;
    padding: 40px;
    border-radius: var(--radius);
    margin-bottom: 40px;
    box-shadow: var(--shadow);
}
.hero h2, .features h2, .pricing h2, .examples h2 {
    color: var(--gray-900);
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.5em;
}
.hero p, .hero li { color: var(--gray-600); margin-bottom: 15px; }
.hero ul { list-style: none; margin: 20px 0; }
.hero li { padding-left: 30px; position: relative; }
.hero li::before { content: ''; position: absolute; left: 0; top: 12px; width: 6px; height: 6px; background: var(--primary); border-radius: 50%; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin: 20px 0; }
.feature-card { padding: 20px; border: 1px solid var(--gray-200); border-radius: var(--radius); }
.feature-card h3 { color: var(--primary); margin-bottom: 10px; }

.pricing { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 30px; }
.plan {
    background: white;
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 2px solid transparent;
}
.plan.pro { border-color: var(--primary); background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), white); transform: scale(1.05); }
.plan h3 { font-size: 1.5em; margin-bottom: 10px; }
.plan .price { font-size: 2em; color: var(--primary); font-weight: bold; margin-bottom: 20px; }
.plan ul { list-style: none; margin-bottom: 30px; }
.plan li { padding: 10px 0; border-bottom: 1px solid var(--gray-100); color: var(--gray-600); }

.examples-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin: 20px 0; }
.example { padding: 15px; background: var(--gray-50); border-radius: var(--radius); border-left: 4px solid var(--primary); }
.example h4 { margin-bottom: 8px; color: var(--gray-900); }
.example code { display: block; font-size: 0.85em; color: var(--danger); word-break: break-all; }

.cta { text-align: center; padding: 60px 20px; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; border-radius: var(--radius); margin-bottom: 40px; }
.cta h2 { color: white; margin-bottom: 30px; }

footer { text-align: center; padding: 30px; color: var(--gray-600); border-top: 1px solid var(--gray-200); }

/* App */
.app-container { background: white; min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.app-header h1 { font-size: 1.5em; }
.header-right { display: flex; gap: 15px; align-items: center; }
.pro-status {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
}
.btn-icon { background: transparent; border: none; color: white; font-size: 1.2em; cursor: pointer; }

.app-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    overflow-y: auto;
}

.input-panel, .results-panel {
    padding: 20px;
    overflow-y: auto;
}

.input-panel { background: var(--gray-50); border-right: 1px solid var(--gray-200); }
.input-panel h2, .results-panel h2 { margin-bottom: 15px; font-size: 1.1em; }

.regex-input { width: 100%; padding: 10px; border: 2px solid var(--gray-300); border-radius: var(--radius); font-family: monospace; margin-bottom: 5px; }
.input-hint { font-size: 0.75em; color: var(--gray-600); display: block; margin-bottom: 15px; }
.flags { display: flex; gap: 15px; margin-bottom: 20px; flex-wrap: wrap; }
.flags label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.test-input { width: 100%; height: 150px; padding: 10px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-family: monospace; resize: vertical; margin-bottom: 15px; }

.quick-patterns { margin-top: 20px; }
.quick-patterns h3 { font-size: 0.9em; margin-bottom: 10px; }
.pattern-btn { padding: 6px 10px; margin: 5px 5px 5px 0; background: var(--secondary); color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 0.8em; }
.pattern-btn:hover { background: var(--primary); }

.match-count { padding: 10px; background: var(--gray-100); border-radius: var(--radius); margin-bottom: 15px; font-weight: bold; }
.test-output, .matches-list { margin-bottom: 20px; }
.highlighted-text {
    background: var(--gray-900);
    color: #0f0;
    padding: 10px;
    border-radius: var(--radius);
    font-family: monospace;
    word-wrap: break-word;
    min-height: 60px;
}
.highlighted-text mark { background: #ffff00; color: #000; padding: 2px; }

.match-item { padding: 8px; background: var(--gray-100); border-radius: 4px; margin-bottom: 8px; display: flex; gap: 10px; align-items: center; font-size: 0.85em; }
.match-num { font-weight: bold; color: var(--primary); }
.match-index { font-size: 0.75em; color: var(--gray-600); }
.no-matches, .empty { text-align: center; padding: 20px; color: var(--gray-600); }

.explanation-section { margin-top: 20px; padding: 15px; background: var(--gray-50); border-radius: var(--radius); }
.regex-explanation { max-height: 200px; overflow-y: auto; }
.explanation-item { padding: 8px 0; border-bottom: 1px solid var(--gray-200); font-size: 0.9em; }
.explanation-tip { padding: 10px; background: #fef3c7; border-left: 4px solid #f59e0b; margin-top: 10px; border-radius: 4px; font-size: 0.85em; }

.history-section { margin-top: 20px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item { padding: 8px; background: white; border: 1px solid var(--gray-200); border-radius: 4px; cursor: pointer; font-size: 0.8em; }
.history-item:hover { background: var(--gray-50); }
.history-meta { float: right; color: var(--gray-600); }

/* Buttons */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-300); color: var(--gray-900); }
.btn-lg { padding: 15px 40px; font-size: 1.1em; }

/* Modal */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal.hidden { display: none; }
.modal-content { background: white; border-radius: var(--radius); padding: 30px; max-width: 500px; width: 90%; max-height: 90vh; overflow-y: auto; position: relative; }
.payment-option { background: var(--gray-50); padding: 15px; border-radius: var(--radius); margin-bottom: 15px; border-left: 4px solid var(--primary); }
.payment-option code { display: block; background: var(--gray-900); color: #0f0; padding: 10px; border-radius: 4px; font-family: monospace; font-size: 0.85em; margin-bottom: 8px; word-break: break-all; }
.btn-close { position: absolute; top: 15px; right: 15px; background: transparent; border: none; font-size: 1.5em; cursor: pointer; }
.unlock-form input { width: 100%; padding: 10px; border: 1px solid var(--gray-300); border-radius: var(--radius); margin-bottom: 10px; }
.unlock-form ol { margin-left: 20px; margin-bottom: 15px; color: var(--gray-600); }

@media (max-width: 1024px) { .app-main { grid-template-columns: 1fr; } }
@media (max-width: 768px) { header h1 { font-size: 2em; } .plan.pro { transform: scale(1); } }
