/* ============================================================
   Regexplorer — Styles
   ============================================================ */

/* --- CSS Variables / Theming --- */
:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    --topbar-h: 50px;
    --regex-bar-h: 56px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition: 0.18s ease;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.15);
}

/* Clean Slate — warm neutral with teal accent */
[data-theme="dark"] {
    --bg: #121316;
    --surface: #1a1b1f;
    --surface-alt: #212226;
    --border: #2e2f35;
    --border-light: #3a3b42;
    --text: #c8c9cf;
    --text-dim: #7d7e87;
    --text-bright: #edeef2;
    --accent: #22c55e;
    --accent-hover: #4ade80;
    --accent-dim: rgba(34, 197, 94, 0.14);
    --accent-dim2: rgba(34, 197, 94, 0.06);
    --match-bg1: rgba(34, 197, 94, 0.2);
    --match-bg2: rgba(56, 189, 248, 0.15);
    --match-border1: rgba(34, 197, 94, 0.5);
    --match-border2: rgba(56, 189, 248, 0.4);
    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.08);
    --warning: #fbbf24;
    --scrollbar-thumb: #2e2f35;
    --scrollbar-track: #121316;
    --modal-bg: rgba(0, 0, 0, 0.6);
    --toast-bg: #1a1b1f;
    --code-bg: #0e0f11;
    --ai-accent: #a78bfa;
    --ai-bg: rgba(167, 139, 250, 0.08);
    --ai-border: rgba(167, 139, 250, 0.2);
}

[data-theme="light"] {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-alt: #fafafa;
    --border: #e2e3e8;
    --border-light: #ecedf2;
    --text: #2c2d31;
    --text-dim: #8b8d96;
    --text-bright: #111214;
    --accent: #16a34a;
    --accent-hover: #15803d;
    --accent-dim: rgba(22, 163, 74, 0.1);
    --accent-dim2: rgba(22, 163, 74, 0.04);
    --match-bg1: rgba(22, 163, 74, 0.14);
    --match-bg2: rgba(14, 165, 233, 0.1);
    --match-border1: rgba(22, 163, 74, 0.45);
    --match-border2: rgba(14, 165, 233, 0.35);
    --error: #dc2626;
    --error-bg: rgba(220, 38, 38, 0.06);
    --warning: #d97706;
    --scrollbar-thumb: #cdced4;
    --scrollbar-track: #f5f5f7;
    --modal-bg: rgba(0, 0, 0, 0.25);
    --toast-bg: #ffffff;
    --code-bg: #f0f1f3;
    --ai-accent: #7c3aed;
    --ai-bg: rgba(124, 58, 237, 0.05);
    --ai-border: rgba(124, 58, 237, 0.15);
}

/* --- Reset / Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

/* --- Selection --- */
::selection {
    background: var(--accent-dim);
    color: var(--text-bright);
}

/* --- Focus --- */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    color: var(--accent);
    display: flex;
    align-items: center;
}

.topbar-title {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.app-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-bright);
    letter-spacing: -0.3px;
}

.app-subtitle {
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 400;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.privacy-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-dim);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 20px;
}

.privacy-badge svg {
    color: var(--accent);
}

.theme-toggle {
    position: relative;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    user-select: none;
    line-height: 1.3;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-secondary {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: transparent;
}
.btn-secondary:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border-color: transparent;
}
.btn-ghost:hover {
    color: var(--text);
    background: var(--surface-alt);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 11px;
}

/* ============================================================
   Regex Input Bar
   ============================================================ */
.regex-bar {
    height: var(--regex-bar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    flex-shrink: 0;
}

.regex-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0 12px;
    height: 38px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.regex-input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.regex-input-wrap.has-error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px var(--error-bg);
}

.regex-delim {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 500;
    color: var(--accent);
    user-select: none;
    line-height: 1;
}

.regex-input {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-bright);
    background: transparent;
    border: none;
    outline: none;
    padding: 0 6px;
    height: 100%;
    min-width: 0;
}

.regex-input::placeholder {
    color: var(--text-dim);
    font-weight: 400;
    font-size: 14px;
}

.flag-toggles {
    display: flex;
    gap: 3px;
    margin-left: 4px;
}

.flag-btn {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}

.flag-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.flag-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* --- AI / Natural Language toggle --- */
.ai-mode-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 8px;
    flex-shrink: 0;
}

.ai-toggle-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.ai-toggle-btn:hover {
    border-color: var(--ai-accent);
    color: var(--ai-accent);
    background: var(--ai-bg);
}

.ai-toggle-btn.active {
    background: var(--ai-bg);
    border-color: var(--ai-accent);
    color: var(--ai-accent);
}

.ai-toggle-btn svg {
    flex-shrink: 0;
}

/* AI input bar shown when AI mode is active */
.ai-input-bar {
    display: none;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    flex-shrink: 0;
    align-items: center;
    gap: 10px;
    height: 48px;
}

.ai-input-bar.visible {
    display: flex;
}

.ai-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--ai-bg);
    border: 1px solid var(--ai-border);
    border-radius: var(--radius-md);
    padding: 0 12px;
    height: 36px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.ai-input-wrap:focus-within {
    border-color: var(--ai-accent);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.1);
}

.ai-input-wrap svg {
    color: var(--ai-accent);
    flex-shrink: 0;
    opacity: 0.7;
}

.ai-input {
    flex: 1;
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-bright);
    background: transparent;
    border: none;
    outline: none;
    height: 100%;
}

.ai-input::placeholder {
    color: var(--text-dim);
}

.ai-generate-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--ai-accent);
    color: #fff;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.ai-generate-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.ai-generate-btn:active {
    transform: scale(0.97);
}

.ai-suggestions {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    flex-shrink: 0;
    padding: 2px 0;
}

.ai-suggestion-chip {
    font-family: var(--font-sans);
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface-alt);
    color: var(--text-dim);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.ai-suggestion-chip:hover {
    border-color: var(--ai-accent);
    color: var(--ai-accent);
    background: var(--ai-bg);
}

.regex-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.match-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

/* ============================================================
   Main Area — Split Layout
   ============================================================ */
.main-area {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.test-panel {
    flex: 0 0 55%;
    border-right: 1px solid var(--border);
}

.results-panel {
    flex: 1;
}

/* --- Panel Resizer --- */
.panel-resizer {
    width: 5px;
    cursor: col-resize;
    background: var(--border);
    flex-shrink: 0;
    transition: background var(--transition);
    position: relative;
}

.panel-resizer:hover,
.panel-resizer.active {
    background: var(--accent);
}

/* --- Panel Toolbar --- */
.panel-toolbar {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.panel-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-actions {
    display: flex;
    gap: 4px;
}

/* ============================================================
   Test Editor
   ============================================================ */
.test-editor-wrap {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
    position: relative;
    background: var(--bg);
}

.line-numbers {
    width: 44px;
    flex-shrink: 0;
    padding: 12px 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-dim);
    text-align: right;
    line-height: 1.65;
    overflow: hidden;
    user-select: none;
}

.line-numbers .ln {
    display: block;
    padding-right: 10px;
    height: 19.5px;
}

.editor-container {
    flex: 1;
    position: relative;
    min-width: 0;
    overflow: auto;
}

.highlight-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: transparent;
    pointer-events: none;
    z-index: 1;
    min-height: 100%;
}

.highlight-layer .match-hl {
    background: var(--match-bg1);
    border-bottom: 2px solid var(--match-border1);
    border-radius: 2px;
    padding: 1px 0;
}

.highlight-layer .match-hl.alt {
    background: var(--match-bg2);
    border-bottom-color: var(--match-border2);
}

.highlight-layer .match-hl.active {
    background: rgba(250, 204, 21, 0.35);
    border-bottom-color: #facc15;
}

.highlight-layer .group-hl {
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}

.test-input {
    position: relative;
    z-index: 2;
    width: 100%;
    min-height: 100%;
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.65;
    color: var(--text);
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    caret-color: var(--accent);
}

.test-input::placeholder {
    color: var(--text-dim);
}

/* ============================================================
   Tabs
   ============================================================ */
.tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
    padding: 0 8px;
    gap: 2px;
}

.tab-btn {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 14px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.tab-content {
    display: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px;
}

.tab-content.active {
    display: block;
}

/* ============================================================
   Matches Tab
   ============================================================ */
.matches-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.match-item {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    cursor: pointer;
    transition: all var(--transition);
}

.match-item:hover {
    border-color: var(--accent);
    background: var(--accent-dim2);
}

.match-item.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.match-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.match-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.match-pos {
    font-size: 11px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.match-text {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-bright);
    background: var(--code-bg);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    word-break: break-all;
}

.match-groups {
    margin-top: 8px;
    padding-left: 12px;
    border-left: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.group-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.group-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    white-space: nowrap;
}

.group-text {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
}

/* ============================================================
   Explain Tab
   ============================================================ */
.explain-tree {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.explain-node {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.explain-node:hover {
    background: var(--surface-alt);
}

.explain-node.indent-1 { padding-left: 28px; }
.explain-node.indent-2 { padding-left: 44px; }
.explain-node.indent-3 { padding-left: 60px; }

.explain-token {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 28px;
    text-align: center;
}

.explain-desc {
    font-size: 12px;
    color: var(--text);
    line-height: 1.6;
    padding-top: 1px;
}

.explain-node.group-start .explain-token {
    color: #f97316;
    background: rgba(249, 115, 22, 0.1);
}

.explain-node.quantifier .explain-token {
    color: #eab308;
    background: rgba(234, 179, 8, 0.1);
}

.explain-node.anchor .explain-token {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
}

.explain-node.charset .explain-token {
    color: #a78bfa;
    background: rgba(167, 139, 250, 0.1);
}

.explain-node.alternation .explain-token {
    color: #f472b6;
    background: rgba(244, 114, 182, 0.1);
}

/* ============================================================
   Cheat Sheet Tab
   ============================================================ */
.cheatsheet {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cs-section {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.cs-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--surface-alt);
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-bright);
    transition: background var(--transition);
}

.cs-header:hover {
    background: var(--accent-dim2);
}

.cs-header .cs-chevron {
    transition: transform var(--transition);
    color: var(--text-dim);
    flex-shrink: 0;
}

.cs-section.open .cs-chevron {
    transform: rotate(90deg);
}

.cs-body {
    display: none;
    padding: 6px;
}

.cs-section.open .cs-body {
    display: block;
}

.cs-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.cs-item:hover {
    background: var(--accent-dim2);
}

.cs-pattern {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    min-width: 64px;
    text-align: center;
    white-space: nowrap;
}

.cs-desc {
    font-size: 12px;
    color: var(--text);
    flex: 1;
}

/* ============================================================
   Library Tab
   ============================================================ */
.library-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0 10px;
    margin-bottom: 12px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.library-search-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.library-search-wrap svg {
    color: var(--text-dim);
    flex-shrink: 0;
}

.library-search {
    flex: 1;
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text);
    background: transparent;
    border: none;
    outline: none;
    padding: 9px 0;
}

.library-search::placeholder {
    color: var(--text-dim);
}

.library-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lib-item {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    cursor: pointer;
    transition: all var(--transition);
}

.lib-item:hover {
    border-color: var(--accent);
    background: var(--accent-dim2);
}

.lib-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 4px;
}

.lib-regex {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent);
    background: var(--code-bg);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    word-break: break-all;
    display: block;
    margin-bottom: 4px;
}

.lib-desc {
    font-size: 11px;
    color: var(--text-dim);
}

/* ============================================================
   Bottom Section
   ============================================================ */
.bottom-section {
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.bottom-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 20px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color var(--transition);
}

.bottom-toggle:hover {
    color: var(--text);
}

.bottom-toggle .chevron {
    transition: transform var(--transition);
}

.bottom-section.open .bottom-toggle .chevron {
    transform: rotate(180deg);
}

.bottom-content {
    display: none;
    padding: 0 20px 14px;
}

.bottom-section.open .bottom-content {
    display: block;
}

.bottom-cols {
    display: flex;
    gap: 20px;
}

.bottom-col {
    flex: 1;
    min-width: 0;
}

.bottom-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.replace-row, .export-row {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.replace-input {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.replace-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.replace-preview {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    max-height: 80px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
}

.replace-preview .replaced {
    background: rgba(34, 197, 94, 0.25);
    border-radius: 2px;
    padding: 0 1px;
}

.lang-select {
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition);
    min-width: 120px;
}

.lang-select:focus {
    border-color: var(--accent);
}

.export-code {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    max-height: 80px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--text-dim);
    text-align: center;
    gap: 12px;
}

.empty-state p {
    font-size: 13px;
    max-width: 240px;
    line-height: 1.6;
}

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--toast-bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 18px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.2s forwards;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.success {
    border-color: var(--accent);
}

.toast.error {
    border-color: var(--error);
    color: var(--error);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(12px); }
}

/* ============================================================
   Modal / Tour
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--modal-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px;
    width: 440px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.visible .modal {
    transform: scale(1);
}

.modal-header {
    text-align: center;
    margin-bottom: 28px;
}

.modal-logo {
    color: var(--accent);
    margin-bottom: 14px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 4px;
}

.modal-subtitle {
    font-size: 13px;
    color: var(--text-dim);
}

.tour-steps {
    position: relative;
    min-height: 140px;
}

.tour-step {
    display: none;
    text-align: center;
    animation: fadeSlideIn 0.3s ease;
}

.tour-step.active {
    display: block;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: translateX(0); }
}

.tour-icon {
    color: var(--accent);
    margin-bottom: 14px;
}

.tour-step h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 6px;
}

.tour-step p {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.7;
    max-width: 320px;
    margin: 0 auto;
}

.tour-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 24px 0;
}

.tour-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    cursor: pointer;
    transition: all var(--transition);
}

.tour-dot.active {
    background: var(--accent);
    width: 20px;
    border-radius: 4px;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ============================================================
   Error display
   ============================================================ */
.regex-error {
    position: absolute;
    top: calc(var(--topbar-h) + var(--regex-bar-h) + 2px);
    left: 20px;
    right: 20px;
    z-index: 50;
    background: var(--error-bg);
    border: 1px solid var(--error);
    color: var(--error);
    font-size: 12px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    animation: fadeSlideIn 0.2s ease;
    pointer-events: none;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .main-area {
        flex-direction: column;
    }
    .test-panel {
        flex: none;
        height: 45%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .panel-resizer {
        display: none;
    }
    .results-panel {
        flex: 1;
    }
    .bottom-cols {
        flex-direction: column;
    }
    .app-subtitle {
        display: none;
    }
    .privacy-badge span {
        display: none;
    }
    .ai-suggestions {
        display: none;
    }
}

/* ============================================================
   Utility
   ============================================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}
