/**
 * Regex Tester App Styles
 *
 * A production-ready regex testing tool with accessible, responsive design
 * Features: Real-time matching, pattern explanation, find/replace, pattern library
 */

/* ========================================
   App Container Centering
   ======================================== */

.app-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

/* ========================================
   Main App Layout
   ======================================== */

.rt-app {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* ========================================
   Controls Bar
   ======================================== */

.rt-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.rt-flavor-selector {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.rt-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
}

.rt-select {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
    background: var(--color-bg-card);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.rt-select:focus {
    outline: none;
    box-shadow: var(--focus-ring);
    border-color: var(--color-primary);
}

.rt-actions {
    display: flex;
    gap: var(--space-2);
}

/* ========================================
   Buttons
   ======================================== */

.rt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast), transform 0.1s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

.rt-btn:active {
    transform: scale(0.98);
}

.rt-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.rt-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rt-btn-primary {
    background: var(--color-primary);
    color: white;
    border: none;
}

.rt-btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.rt-btn-secondary {
    background: var(--color-bg-card);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.rt-btn-secondary:hover:not(:disabled) {
    background: var(--color-bg-alt);
}

.rt-btn-small {
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
}

.rt-btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--color-bg-card);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.rt-btn-icon:hover:not(:disabled) {
    background: var(--color-bg-alt);
    color: var(--color-primary);
}

/* ========================================
   Pattern Input Section
   ======================================== */

.rt-pattern-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.rt-pattern-row {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

.rt-pattern-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--color-bg-alt);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
}

.rt-pattern-wrapper:focus-within {
    border-color: var(--color-primary);
}

.rt-pattern-delim {
    padding: 0 var(--space-2);
    font-size: var(--font-size-lg);
    font-family: var(--font-family-mono);
    color: var(--color-text-muted);
    user-select: none;
}

.rt-pattern-input {
    flex: 1;
    padding: var(--space-3);
    font-size: var(--font-size-base);
    font-family: var(--font-family-mono);
    background: transparent;
    color: var(--color-text);
    border: none;
    min-width: 0;
}

.rt-pattern-input:focus {
    outline: none;
}

.rt-pattern-input::placeholder {
    color: var(--color-text-muted);
}

.rt-flags-wrapper {
    display: flex;
    align-items: center;
    border-left: 1px solid var(--color-border);
}

.rt-flags-input {
    width: 60px;
    padding: var(--space-3) var(--space-2);
    font-size: var(--font-size-base);
    font-family: var(--font-family-mono);
    background: transparent;
    color: var(--color-text);
    border: none;
    text-align: center;
}

.rt-flags-input:focus {
    outline: none;
}

.rt-pattern-actions {
    display: flex;
    gap: var(--space-2);
}

/* Flags Checkboxes */
.rt-flags-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.rt-flag-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    cursor: pointer;
    user-select: none;
}

.rt-flag-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.rt-flag-key {
    font-family: var(--font-family-mono);
    font-weight: 600;
    color: var(--color-primary);
}

.rt-flag-desc {
    color: var(--color-text-muted);
}

/* Pattern Error */
.rt-pattern-error {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-error, #ef4444);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
}

.rt-pattern-error[hidden] {
    display: none;
}

/* ========================================
   Main Content Grid
   ======================================== */

.rt-main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
    min-height: 300px;
}

/* ========================================
   Panels
   ======================================== */

.rt-panel {
    display: flex;
    flex-direction: column;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.rt-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg-alt);
    border-bottom: 1px solid var(--color-border);
}

.rt-panel-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
}

.rt-panel-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* ========================================
   Test String Panel with Highlight Overlay
   ======================================== */

.rt-test-wrapper {
    position: relative;
    height: 100%;
    min-height: 250px;
}

.rt-highlight-layer {
    position: absolute;
    inset: 0;
    padding: var(--space-4);
    font-size: var(--font-size-sm);
    font-family: var(--font-family-mono);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    pointer-events: none;
    overflow: auto;
    color: transparent;
    background: transparent;
}

.rt-test-input {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    min-height: 250px;
    padding: var(--space-4);
    font-size: var(--font-size-sm);
    font-family: var(--font-family-mono);
    line-height: 1.6;
    color: var(--color-text);
    background: transparent;
    border: none;
    resize: none;
    caret-color: var(--color-text);
}

.rt-test-input:focus {
    outline: none;
}

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

/* Match highlighting */
.rt-match {
    background: var(--match-bg, rgba(79, 70, 229, 0.3));
    border-radius: 2px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

.rt-match-alt {
    background: var(--match-alt-bg, rgba(236, 72, 153, 0.3));
}

/* Match count badge */
.rt-match-count {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.rt-match-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 var(--space-2);
    font-size: var(--font-size-xs);
    font-weight: 600;
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-full);
}

/* ========================================
   Pattern Explanation Panel
   ======================================== */

.rt-explanation {
    padding: var(--space-4);
    font-size: var(--font-size-sm);
    line-height: 1.7;
    overflow-y: auto;
    height: 100%;
}

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

.rt-explanation-item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border);
}

.rt-explanation-item:last-child {
    border-bottom: none;
}

.rt-explanation-token {
    flex-shrink: 0;
    padding: var(--space-1) var(--space-2);
    font-family: var(--font-family-mono);
    font-weight: 600;
    background: var(--color-bg-alt);
    color: var(--color-primary);
    border-radius: var(--radius-sm);
}

.rt-explanation-text {
    color: var(--color-text);
}

/* ========================================
   Replace Section
   ======================================== */

.rt-replace-section {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.rt-replace-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: 500;
    background: var(--color-bg-alt);
    color: var(--color-text);
    cursor: pointer;
    user-select: none;
}

.rt-replace-header svg {
    transition: transform var(--transition-fast);
}

.rt-replace-section[open] .rt-replace-header svg {
    transform: rotate(90deg);
}

.rt-replace-content {
    padding: var(--space-4);
    background: var(--color-bg-card);
    border-top: 1px solid var(--color-border);
}

.rt-replace-input-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.rt-replace-input-row .rt-label {
    flex-shrink: 0;
}

.rt-input {
    flex: 1;
    padding: var(--space-3);
    font-size: var(--font-size-sm);
    font-family: var(--font-family-mono);
    background: var(--color-bg-alt);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.rt-input:focus {
    outline: none;
    box-shadow: var(--focus-ring);
    border-color: var(--color-primary);
}

.rt-input::placeholder {
    color: var(--color-text-muted);
}

.rt-replace-preview {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.rt-preview-output {
    padding: var(--space-4);
    font-size: var(--font-size-sm);
    font-family: var(--font-family-mono);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: var(--color-bg-alt);
    color: var(--color-text);
    min-height: 80px;
    max-height: 200px;
    overflow-y: auto;
}

/* ========================================
   Match Details Section
   ======================================== */

.rt-matches-section {
    padding: var(--space-4);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.rt-matches-section[hidden] {
    display: none;
}

.rt-matches-section .rt-panel-header {
    background: transparent;
    border-bottom: none;
    padding: 0 0 var(--space-3) 0;
}

.rt-matches-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-height: 300px;
    overflow-y: auto;
}

.rt-match-item {
    padding: var(--space-3);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.rt-match-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.rt-match-index {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-muted);
}

.rt-match-position {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.rt-match-value {
    padding: var(--space-2);
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    background: var(--color-bg-card);
    border-radius: var(--radius-sm);
    word-break: break-all;
}

.rt-match-groups {
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
}

.rt-match-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.rt-match-group-index {
    font-weight: 600;
    color: var(--color-primary);
}

/* ========================================
   Modal Panels (Library, Cheatsheet, Saved)
   ======================================== */

.rt-library-panel,
.rt-cheatsheet-panel,
.rt-saved-panel {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.rt-library-panel[hidden],
.rt-cheatsheet-panel[hidden],
.rt-saved-panel[hidden] {
    display: none;
}

.rt-library-modal,
.rt-cheatsheet-modal,
.rt-saved-modal {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}

.rt-library-header,
.rt-cheatsheet-header,
.rt-saved-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.rt-library-header h2,
.rt-cheatsheet-header h2,
.rt-saved-header h2 {
    font-size: var(--font-size-lg);
    margin: 0;
}

.rt-library-search {
    flex: 1;
    max-width: 250px;
}

.rt-library-body,
.rt-cheatsheet-body,
.rt-saved-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
}

/* Pattern Library Items */
.rt-library-item {
    padding: var(--space-3);
    margin-bottom: var(--space-2);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.rt-library-item:hover {
    border-color: var(--color-primary);
}

.rt-library-item:focus {
    outline: none;
    box-shadow: var(--focus-ring);
}

.rt-library-item-name {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-1);
}

.rt-library-item-pattern {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    margin-bottom: var(--space-2);
    word-break: break-all;
}

.rt-library-item-desc {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* Cheatsheet Categories */
.rt-cheatsheet-category {
    margin-bottom: var(--space-6);
}

.rt-cheatsheet-category:last-child {
    margin-bottom: 0;
}

.rt-cheatsheet-category h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: var(--space-3);
    color: var(--color-text);
}

.rt-cheatsheet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-2);
}

.rt-cheatsheet-item {
    padding: var(--space-2) var(--space-3);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    text-align: left;
}

.rt-cheatsheet-item:hover {
    border-color: var(--color-primary);
    background: var(--color-bg-card);
}

.rt-cheatsheet-item:focus {
    outline: none;
    box-shadow: var(--focus-ring);
}

.rt-cheatsheet-token {
    display: block;
    font-family: var(--font-family-mono);
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: var(--space-1);
}

.rt-cheatsheet-desc {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Saved Patterns List */
.rt-saved-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3);
    margin-bottom: var(--space-2);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.rt-saved-item-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.rt-saved-item-name {
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: var(--space-1);
}

.rt-saved-item-pattern {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rt-saved-item-actions {
    display: flex;
    gap: var(--space-1);
}

.rt-saved-empty {
    text-align: center;
    padding: var(--space-8);
    color: var(--color-text-muted);
}

/* ========================================
   Dark Theme
   ======================================== */

:root[data-theme="dark"] {
    --match-bg: rgba(99, 102, 241, 0.4);
    --match-alt-bg: rgba(236, 72, 153, 0.4);
}

/* ========================================
   Use Cases Section
   ======================================== */

.use-cases {
    margin-top: var(--space-8);
    padding: var(--space-6);
    background: var(--color-bg-alt);
    border-radius: var(--radius-lg);
}

.use-cases h2 {
    font-size: var(--font-size-xl);
    margin-bottom: var(--space-3);
    text-align: center;
}

.use-cases-intro {
    text-align: center;
    color: var(--color-text-muted);
    margin-bottom: var(--space-6);
}

.use-cases-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-4);
    list-style: none;
    padding: 0;
    margin: 0;
}

.use-cases-list li {
    padding: var(--space-4);
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.use-cases-list strong {
    display: block;
    margin-bottom: var(--space-2);
    color: var(--color-text);
}

.use-cases-list p {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* ========================================
   FAQ Section
   ======================================== */

.faq-section {
    margin-top: var(--space-8);
    padding: var(--space-6);
    background: var(--color-bg-alt);
    border-radius: var(--radius-lg);
}

.faq-section h2 {
    font-size: var(--font-size-xl);
    margin-bottom: var(--space-6);
    text-align: center;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    max-width: 800px;
    margin: 0 auto;
}

.faq-item {
    padding: var(--space-4);
    background: var(--color-bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.faq-item dt {
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--color-text);
}

.faq-item dd {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    line-height: 1.6;
}

/* ========================================
   Help Panel (Modal)
   ======================================== */

.help-panel {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.help-panel[hidden] {
    display: none;
}

.help-modal-content {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    max-width: 550px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    background: var(--color-bg-card);
}

.help-header h2 {
    font-size: var(--font-size-lg);
    margin: 0;
}

.help-body {
    padding: var(--space-6);
}

.help-section {
    margin-bottom: var(--space-6);
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: var(--space-3);
    color: var(--color-text);
}

.help-section ol,
.help-section ul {
    padding-left: var(--space-5);
    margin: 0;
}

.help-section li {
    margin-bottom: var(--space-2);
    color: var(--color-text-muted);
}

.keyboard-shortcuts {
    width: 100%;
    border-collapse: collapse;
}

.keyboard-shortcuts td {
    padding: var(--space-2);
    color: var(--color-text-muted);
}

.keyboard-shortcuts td:first-child {
    white-space: nowrap;
}

.keyboard-shortcuts kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: var(--font-size-xs);
    font-family: var(--font-family-mono);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.close-help {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xl);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
}

.close-help:hover {
    background: var(--color-bg-alt);
    color: var(--color-text);
}

.close-help:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ========================================
   Responsive Design
   ======================================== */

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

    .rt-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .rt-flavor-selector {
        justify-content: space-between;
    }

    .rt-actions {
        justify-content: center;
    }

    .rt-pattern-row {
        flex-direction: column;
        align-items: stretch;
    }

    .rt-pattern-actions {
        justify-content: center;
    }

    .rt-flags-checkboxes {
        flex-direction: column;
        gap: var(--space-2);
    }

    .rt-replace-input-row {
        flex-direction: column;
        align-items: stretch;
    }

    .rt-replace-input-row .rt-btn {
        width: 100%;
    }

    .rt-library-header,
    .rt-cheatsheet-header,
    .rt-saved-header {
        flex-wrap: wrap;
    }

    .rt-library-search {
        order: 3;
        max-width: none;
        width: 100%;
        margin-top: var(--space-3);
    }
}

@media (max-width: 480px) {
    .rt-test-wrapper,
    .rt-test-input {
        min-height: 200px;
    }

    .rt-cheatsheet-grid {
        grid-template-columns: 1fr 1fr;
    }

    .rt-pattern-wrapper {
        flex-wrap: wrap;
    }

    .rt-flags-wrapper {
        border-left: none;
        border-top: 1px solid var(--color-border);
        width: 100%;
    }

    .rt-flags-input {
        width: 100%;
    }
}

/* ========================================
   RTL Support
   ======================================== */

[dir="rtl"] .rt-pattern-row {
    flex-direction: row-reverse;
}

[dir="rtl"] .rt-flags-wrapper {
    border-left: none;
    border-right: 1px solid var(--color-border);
}

[dir="rtl"] .rt-replace-header svg {
    transform: rotate(180deg);
}

[dir="rtl"] .rt-replace-section[open] .rt-replace-header svg {
    transform: rotate(90deg);
}

/* Code content is always LTR */
.rt-pattern-input,
.rt-flags-input,
.rt-test-input,
.rt-input,
.rt-preview-output,
.rt-explanation-token,
.rt-library-item-pattern,
.rt-cheatsheet-token,
.rt-saved-item-pattern,
.rt-match-value {
    direction: ltr;
    text-align: left;
}

/* ========================================
   Reduced Motion
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .rt-btn,
    .rt-select,
    .rt-input,
    .rt-pattern-wrapper,
    .rt-library-item,
    .rt-cheatsheet-item,
    .rt-replace-header svg {
        transition: none;
    }

    .rt-btn:active {
        transform: none;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .rt-controls,
    .rt-pattern-actions,
    .rt-replace-section,
    .rt-matches-section,
    .rt-library-panel,
    .rt-cheatsheet-panel,
    .rt-saved-panel,
    .help-panel,
    .nav-actions {
        display: none;
    }

    .rt-main-grid {
        display: block;
    }

    .rt-panel {
        page-break-inside: avoid;
        margin-bottom: var(--space-4);
    }
}
