:root {
    /* Ocean Depths Palette */
    --primary: #0984E3;
    --primary-hover: #076fc2;
    --secondary: #74B9FF;
    --accent: #00CEC9;
    --background: #0A1628;
    --surface: #142844;

    --glass-bg: rgba(20, 40, 68, 0.6);
    --glass-border: rgba(116, 185, 255, 0.15);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-error: #ef4444;

    --radius: 12px;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    min-height: 100vh;
}

.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at 85% 30%, rgba(9, 132, 227, 0.1), transparent 45%),
        radial-gradient(circle at 15% 70%, rgba(0, 206, 201, 0.1), transparent 45%);
}

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

header {
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.25rem;
    color: var(--text-main);
    letter-spacing: -0.02em;
    font-weight: 700;
}

header p {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-top: 0.5rem;
}

/* Utilities */
.mt-2 {
    margin-top: 0.5rem;
}

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

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

.flex-row {
    display: flex;
}

.align-center {
    align-items: center;
}

.gap-2 {
    gap: 1rem;
}

.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.font-mono {
    font-family: 'Fira Code', monospace;
}

/* Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

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

.panel-header h2 {
    font-size: 1.25rem;
    color: var(--text-main);
}

/* Inputs */
.regex-input-wrapper {
    display: flex;
    align-items: stretch;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
}

.regex-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(9, 132, 227, 0.2);
}

.regex-slash {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    color: var(--accent);
    font-weight: 700;
    font-size: 1.2rem;
    background: rgba(0, 206, 201, 0.1);
}

.input-control {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 1rem;
    font-size: 1.1rem;
    outline: none;
    width: 100%;
}

.flags-control {
    flex: 0 0 80px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--secondary);
}

/* Chips */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    background: rgba(9, 132, 227, 0.2);
    border-color: var(--primary);
    color: var(--text-main);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.btn-outline:hover {
    background: rgba(116, 185, 255, 0.1);
}

/* Diagram Area */
.diagram-container {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 2rem;
    min-height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: auto;
}

.error-state {
    color: var(--text-error);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-state::before {
    content: "⚠️";
}

/* SVG Styles */
.railroad-svg {
    font-family: 'Fira Code', monospace;
    font-size: 14px;
}

.railroad-svg path {
    stroke: var(--secondary);
    stroke-width: 2;
    fill: none;
}

.railroad-svg rect {
    fill: rgba(9, 132, 227, 0.15);
    stroke: var(--primary);
    stroke-width: 2;
    rx: 4;
    ry: 4;
}

.railroad-svg text {
    fill: var(--text-main);
    text-anchor: middle;
    dominant-baseline: central;
}

.railroad-svg .group-rect {
    fill: rgba(255, 255, 255, 0.02);
    stroke: rgba(255, 255, 255, 0.2);
    stroke-dasharray: 4 4;
    stroke-width: 1;
}

.railroad-svg .group-label {
    fill: var(--text-muted);
    font-size: 10px;
    text-anchor: start;
    dominant-baseline: hanging;
}

/* Explanation */
.explanation-panel h3 {
    font-size: 1rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.explanation-content {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 1rem;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #e2e8f0;
}

.explanation-content ul {
    list-style-type: none;
}

.explanation-content li {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
}

.explanation-content li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--accent);
}

.explanation-content .hlt {
    background: rgba(116, 185, 255, 0.2);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
}

.explanation-content.empty {
    color: var(--text-muted);
    font-style: italic;
}

/* Tester Area */
.tester-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.tester-input textarea {
    resize: vertical;
    width: 100%;
    min-height: 150px;
}

.tester-results {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    overflow-y: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

.match-hlt {
    background-color: rgba(9, 132, 227, 0.4);
    border-radius: 2px;
    outline: 1px solid var(--primary);
}

.no-matches {
    color: var(--text-muted);
    font-style: italic;
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: center;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: #000;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

.toast.show {
    opacity: 1;
}

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