:root {
    --rt-accent: #10b981;
    --rt-navy: #1e2a4a;
    --rt-border: #d1d5db;
}

/* .ic-wrap box model (max-width/padding/margin) is owned centrally by
   dev-tool.css's ".dev-tool-widget .ic-wrap" rule — not redefined here
   to avoid the two paddings stacking and misaligning tool content. */

.ic-note {
    font-size: 13px;
    color: #6b7280;
    margin-top: 16px;
    line-height: 1.6;
}

/* ==== Pattern input row ==== */
.rt-pattern-row {
    margin-bottom: 14px;
}

.rt-pattern-box {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1px solid var(--rt-border);
    border-radius: 8px;
    padding: 12px 16px;
}

.rt-slash {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 18px;
    color: var(--rt-accent);
    font-weight: 700;
}

.rt-pattern-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 15px;
    color: var(--rt-navy);
    min-width: 0;
}

.rt-flags-display {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 15px;
    color: var(--rt-accent);
    font-weight: 700;
    min-width: 14px;
}

/* ==== ACTION BAR (flags + buttons) ==== */
.ic-actionbar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.ic-btn {
    background: var(--rt-navy);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 7px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.ic-btn:hover {
    background: #16213e;
}

.ic-btn-outline {
    background: #fff;
    color: var(--rt-navy);
    border: 1px solid var(--rt-border);
}

.ic-btn-outline:hover {
    border-color: var(--rt-navy);
    background: #f9fafb;
}

.rt-flag-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--rt-navy);
    background: #fff;
    border: 1px solid var(--rt-border);
    border-radius: 7px;
    padding: 9px 12px;
    cursor: pointer;
    white-space: nowrap;
}

.rt-flag-toggle:has(input:checked) {
    border-color: var(--rt-accent);
    background: #ecfdf5;
}

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

.rt-flag-toggle em {
    font-style: normal;
    color: #6b7280;
    font-weight: 500;
}

/* ==== Error box ==== */
.rt-error {
    display: none;
    padding: 10px 14px;
    background: #fef2f2;
    color: #dc2626;
    font-size: 12.5px;
    font-weight: 600;
    border: 1px solid #fecaca;
    border-radius: 8px;
    margin-bottom: 14px;
}

.rt-error.rt-show {
    display: block;
}

/* ==== Two-panel layout, flush shared border ==== */
.rt-panels {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0;
    border: 1px solid var(--rt-border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 18px;
}

.rt-panel {
    background: #fff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.rt-panel:first-child {
    border-right: 1px solid var(--rt-border);
}

.rt-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f9fafb;
    border-bottom: 1px solid var(--rt-border);
    font-size: 13px;
    font-weight: 700;
    color: var(--rt-navy);
}

.rt-copy-btn {
    background: none;
    border: 1px solid var(--rt-border);
    color: var(--rt-navy);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

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

.rt-copy-btn.rt-copied {
    background: var(--rt-accent);
    border-color: var(--rt-accent);
    color: #fff;
}

.rt-textarea {
    flex: 1;
    min-height: 220px;
    border: none;
    resize: vertical;
    padding: 14px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--rt-navy);
    background: #fff;
}

.rt-textarea:focus {
    outline: none;
}

.rt-textarea[readonly] {
    background: #f9fafb;
    color: #374151;
}

.rt-highlighted {
    flex: 1;
    min-height: 220px;
    padding: 14px;
    overflow: auto;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--rt-navy);
    white-space: pre-wrap;
    word-break: break-word;
    background: #f9fafb;
}

.rt-mark {
    background: #d1fae5;
    color: #0d9668;
    border-radius: 3px;
    padding: 1px 2px;
    font-weight: 700;
}

/* ==== Match details ==== */
.rt-matches-section {
    background: #fff;
    border: 1px solid var(--rt-border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 18px;
}

.rt-matches-title {
    padding: 10px 14px;
    background: #f9fafb;
    border-bottom: 1px solid var(--rt-border);
    font-size: 13px;
    font-weight: 700;
    color: var(--rt-navy);
}

.rt-match-list {
    max-height: 260px;
    overflow-y: auto;
}

.rt-match-empty {
    padding: 16px;
    font-size: 13px;
    color: #9ca3af;
    text-align: center;
}

.rt-match-row {
    padding: 10px 14px;
    border-bottom: 1px solid var(--rt-border);
    font-size: 12.5px;
}

.rt-match-row:last-child {
    border-bottom: none;
}

.rt-match-index {
    color: var(--rt-accent);
    font-weight: 700;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    margin-right: 8px;
}

.rt-match-text {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    color: var(--rt-navy);
    font-weight: 700;
    background: #f3f4f6;
    padding: 1px 5px;
    border-radius: 4px;
}

.rt-match-pos {
    color: #9ca3af;
    margin-left: 8px;
}

.rt-match-groups {
    margin-top: 4px;
    padding-left: 20px;
    color: #6b7280;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* ==== Replace section ==== */
.rt-replace-row {
    margin-bottom: 10px;
}

.rt-replace-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--rt-navy);
    margin-bottom: 6px;
}

.rt-replace-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--rt-border);
    border-radius: 7px;
    padding: 10px 12px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    color: var(--rt-navy);
}

.rt-replace-input:focus {
    outline: none;
    border-color: var(--rt-accent);
}

.rt-replace-section .rt-panel {
    border: 1px solid var(--rt-border);
    border-radius: 10px;
}

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

    .rt-panel:first-child {
        border-right: none;
        border-bottom: 1px solid var(--rt-border);
    }

    .rt-textarea,
    .rt-highlighted {
        min-height: 200px;
    }

    .ic-actionbar {
        flex-direction: column;
        align-items: stretch;
    }

    .ic-actionbar .ic-btn {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .rt-flag-toggle {
        justify-content: center;
    }
}
