:root {
    /* Solar Flare Palette */
    --primary: #FDCB6E;
    --primary-glow: rgba(253, 203, 110, 0.4);
    --secondary: #FFEAA7;
    --accent: #E17055;
    --accent-glow: rgba(225, 112, 85, 0.4);

    --bg-dark: #2A2210;
    --bg-panel: #3D321A;
    --bg-input: #4F432A;

    --text-main: #FFFFFF;
    --text-muted: #D1C8B4;
    --border: #6B5B3E;

    --success: #55E19D;
    --success-glow: rgba(85, 225, 157, 0.3);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.code-font {
    font-family: var(--font-mono);
}

.mt-1 {
    margin-top: 1rem;
}

.mt-2 {
    margin-top: 2rem;
}

/* Base Components */
.layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(61, 50, 26, 0.7);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    outline: none;
}

.primary-btn {
    background: var(--primary);
    color: #1A150A;
    /* Very dark contrast */
    box-shadow: 0 4px 14px var(--primary-glow);
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
    background: #FFD68A;
}

.secondary-btn {
    background: rgba(253, 203, 110, 0.15);
    color: var(--secondary);
    border: 1px solid rgba(253, 203, 110, 0.3);
}

.secondary-btn:hover {
    background: rgba(253, 203, 110, 0.25);
    color: white;
}

.outline-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.outline-btn:hover {
    background: var(--bg-input);
    color: white;
}

.sm-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.full-width {
    width: 100%;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    color: var(--primary);
    background: rgba(253, 203, 110, 0.1);
}

.modern-input,
.modern-select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: white;
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: var(--transition);
}

textarea.modern-input {
    resize: vertical;
    min-height: 120px;
}

.modern-input:focus,
.modern-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(253, 203, 110, 0.2);
}

/* Workspace */
.workspace {
    flex-grow: 1;
    display: flex;
    overflow: hidden;
    background: radial-gradient(circle at center, rgba(225, 112, 85, 0.05), transparent 60%);
}

.panel {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.input-panel {
    border-right: 1px solid var(--border);
    max-width: 450px;
    background: rgba(36, 23, 68, 0.02);
}

.output-panel {
    flex-grow: 1;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
}

.badge {
    background: rgba(225, 112, 85, 0.2);
    color: var(--accent);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-title {
    font-size: 0.95rem;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Checkboxes */
.checkbox-grid {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.flag-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.flag-label code {
    background: var(--bg-panel);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    color: var(--primary);
    font-weight: 700;
}

input[type="checkbox"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Format Wrapper */
.format-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.format-header h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.format-header select {
    width: auto;
    padding: 0.4rem 0.8rem;
}

.code-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.code-wrapper input {
    padding-right: 3rem;
    color: var(--success);
    font-weight: 500;
}

.code-wrapper .icon-btn {
    position: absolute;
    right: 0.5rem;
}

/* Result Box */
.result-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

.regex-display {
    font-size: 1.75rem;
    color: var(--primary);
    word-break: break-all;
    font-weight: 600;
    text-align: center;
}

/* Explanation */
.explanation-list {
    list-style: none;
    background: var(--bg-panel);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 1rem;
}

.explanation-list li {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.explanation-list li:last-child {
    border-bottom: none;
}

.explanation-list li code {
    background: var(--bg-input);
    color: var(--accent);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
}

.empty-state {
    color: var(--text-muted);
    font-style: italic;
    justify-content: center;
    padding: 2rem !important;
}

/* Testing Box */
.testing-box {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.test-editor-container {
    flex-grow: 1;
    position: relative;
    background: var(--bg-panel);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
    min-height: 200px;
}

.test-highlight-layer,
.test-textarea {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1.5rem;
    font-size: 1rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
}

.test-textarea {
    color: transparent;
    background: transparent;
    caret-color: var(--text-main);
    border: none;
    resize: none;
    z-index: 2;
}

.test-textarea:focus {
    outline: none;
    box-shadow: inset 0 0 0 1px var(--primary);
}

.test-highlight-layer {
    color: var(--text-muted);
    z-index: 1;
    pointer-events: none;
}

.hl-match {
    background: var(--success-glow);
    color: var(--success);
    border-radius: 3px;
    border-bottom: 2px solid var(--success);
}

.match-stats {
    padding: 0.75rem 0;
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 101;
}

.modal-content {
    position: relative;
    z-index: 102;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
}

.lib-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.lib-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    background: rgba(79, 67, 42, 0.8);
}

.lib-card h3 {
    font-size: 1rem;
    color: white;
    margin-bottom: 0.5rem;
}

.lib-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.4;
}

.lib-card code {
    display: block;
    background: var(--bg-panel);
    color: var(--primary);
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    word-break: break-all;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--success);
    color: #1A150A;
    padding: 1rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: 0 10px 25px var(--success-glow);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.toast.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}