/* ============================================================
   正则表达式测试器 · 专属样式
   迪妙网络空间安全学院 · 纯前端本地工具
   桌面端 .navbar / .logo / .footer 样式由官网 ../../style.css 决定
   ============================================================ */

:root {
    --rt-mono: 'JetBrains Mono', Consolas, 'Courier New', monospace;
    --rt-mark: rgba(255, 107, 53, 0.28);
    --rt-mark-border: #ff6b35;
    --rt-code-bg: #f4f6fb;
}

/* ===== 面包屑 ===== */
.rt-breadcrumb {
    padding: 96px 0 0;
    font-size: 13px;
    color: var(--text-light);
}
.rt-breadcrumb a { color: var(--primary); text-decoration: none; }
.rt-breadcrumb a:hover { text-decoration: underline; }
.rt-breadcrumb .sep { margin: 0 8px; color: var(--border); }
.rt-breadcrumb .current { color: var(--text-secondary); font-weight: 500; }

/* ===== 主体 ===== */
.rt-main { padding: 20px 0 72px; }
.rt-main .container { max-width: 1280px; }

/* ===== 工具头 ===== */
.rt-header { margin-bottom: 24px; }
.rt-title-row { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.rt-icon {
    width: 56px; height: 56px;
    background: var(--primary-light);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}
.rt-header h1 {
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 800;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 6px;
}
.rt-sub {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    max-width: 760px;
}
.rt-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.rt-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 5px 14px;
    border-radius: 100px;
    border: 1px solid rgba(26, 110, 255, 0.12);
}
.rt-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
    border-radius: var(--radius);
    padding: 20px 24px;
}
.rt-stat { text-align: center; }
.rt-stat strong {
    display: block;
    font-size: 24px;
    font-weight: 900;
    color: #ff6b35;
    font-family: var(--rt-mono);
    line-height: 1.1;
}
.rt-stat span { font-size: 12px; color: rgba(255,255,255,0.55); margin-top: 4px; display: block; }

/* ===== 正则输入区 ===== */
.rt-pattern-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.rt-pattern-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.rt-pattern-label svg { color: var(--primary); }
.rt-pattern-hint { font-size: 12px; font-weight: 400; color: var(--text-light); }
.rt-pattern-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--rt-code-bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    transition: var(--transition);
}
.rt-pattern-input-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 110, 255, 0.12);
}
.rt-slash { font-family: var(--rt-mono); color: var(--text-light); font-size: 18px; user-select: none; }
.rt-pattern-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-family: var(--rt-mono);
    font-size: 15px;
    color: var(--text);
    padding: 13px 0;
    min-width: 0;
}
.rt-pattern-input::placeholder { color: var(--text-light); font-family: var(--text, 'Noto Sans SC'); font-size: 13px; }

/* 标志勾选 */
.rt-flags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.rt-flag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1.5px solid var(--border);
    border-radius: 100px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    background: white;
}
.rt-flag:hover { border-color: var(--primary); color: var(--primary); }
.rt-flag input { accent-color: var(--primary); margin: 0; cursor: pointer; }
.rt-flag.on {
    background: var(--primary-gradient);
    border-color: transparent;
    color: white;
    box-shadow: 0 3px 10px rgba(26, 110, 255, 0.28);
}
.rt-flag.on input { accent-color: white; }
.rt-flag .rt-flag-name { font-weight: 700; font-family: var(--rt-mono); }
.rt-flag .rt-flag-desc { opacity: 0.75; }

.rt-error {
    margin-top: 12px;
    background: var(--danger-light);
    border: 1px solid rgba(220, 38, 38, 0.25);
    color: var(--danger);
    font-size: 13px;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-family: var(--rt-mono);
}

/* ===== 工作区布局 ===== */
.rt-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

/* ===== 编辑器 ===== */
.rt-editor {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.rt-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-warm);
    flex-wrap: wrap;
}
.rt-editor-title { font-size: 14px; font-weight: 700; color: var(--text); margin-right: auto; }
.rt-select {
    font-family: inherit;
    font-size: 12px;
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    background: white;
    max-width: 180px;
    cursor: pointer;
}
.rt-mini-btn {
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 6px 14px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.rt-mini-btn:hover { border-color: var(--primary); color: var(--primary); }
.rt-mini-btn.primary {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 3px 10px rgba(26, 110, 255, 0.28);
}
.rt-mini-btn.primary:hover { transform: translateY(-1px); }

.rt-editor-wrap {
    position: relative;
    height: 430px;
    background: #fbfcfe;
}
.rt-highlight, .rt-textarea {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 16px;
    font-family: var(--rt-mono);
    font-size: 13.5px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
    tab-size: 4;
}
.rt-highlight { pointer-events: none; color: var(--text); z-index: 1; }
.rt-textarea {
    z-index: 2;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: transparent;
    caret-color: var(--primary);
}
.rt-textarea::placeholder { color: var(--text-light); }
.rt-highlight .mk {
    background: var(--rt-mark);
    border-bottom: 2px solid var(--rt-mark-border);
    border-radius: 3px;
    color: inherit;
}
.rt-highlight .nl { display: block; }

.rt-editor-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-light);
}
.rt-dot { opacity: 0.5; }

/* ===== 右侧面板 ===== */
.rt-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.rt-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg-warm);
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}
.rt-tabs::-webkit-scrollbar { display: none; }
.rt-tab {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2.5px solid transparent;
    padding: 13px 18px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.rt-tab:hover { color: var(--primary); }
.rt-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.rt-tab-body { display: none; padding: 16px; overflow-y: auto; height: 478px; }
.rt-tab-body.active { display: block; }

/* ===== 匹配结果 ===== */
.rt-result-summary {
    font-size: 12px;
    color: var(--text-light);
    background: var(--bg-warm);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    line-height: 1.6;
}
.rt-match-list { display: flex; flex-direction: column; gap: 8px; }
.rt-match-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    transition: var(--transition);
    cursor: pointer;
}
.rt-match-item:hover, .rt-match-item.sel {
    border-color: rgba(26, 110, 255, 0.35);
    background: var(--primary-light);
}
.rt-match-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.rt-match-idx {
    font-family: var(--rt-mono);
    font-size: 11px;
    font-weight: 700;
    color: white;
    background: var(--primary-gradient);
    border-radius: 6px;
    padding: 2px 8px;
}
.rt-match-pos { font-size: 11px; color: var(--text-light); font-family: var(--rt-mono); }
.rt-match-text {
    font-family: var(--rt-mono);
    font-size: 13px;
    color: var(--text);
    background: var(--rt-code-bg);
    border-radius: 6px;
    padding: 6px 10px;
    word-break: break-all;
    margin-bottom: 6px;
}
.rt-group-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rt-group-chip {
    font-size: 11px;
    font-family: var(--rt-mono);
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 8px;
    color: var(--text-secondary);
    word-break: break-all;
}
.rt-group-chip b { color: var(--primary); font-weight: 700; }
.rt-group-chip.named b { color: #7c3aed; }
.rt-empty {
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
    padding: 40px 16px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}

/* ===== 替换测试 ===== */
.rt-replace-input-row { display: flex; gap: 8px; margin-bottom: 10px; }
.rt-replace-input {
    flex: 1;
    min-width: 0;
    font-family: var(--rt-mono);
    font-size: 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    outline: none;
    transition: var(--transition);
}
.rt-replace-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26, 110, 255, 0.12); }
.rt-token-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.rt-token {
    font-family: var(--rt-mono);
    font-size: 11px;
    background: var(--rt-code-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 9px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}
.rt-token:hover { border-color: var(--primary); color: var(--primary); }
.rt-replace-out-wrap { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.rt-replace-out-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-warm);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.rt-replace-out {
    margin: 0;
    padding: 12px;
    font-family: var(--rt-mono);
    font-size: 12.5px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 260px;
    overflow: auto;
    color: var(--text);
    background: #fbfcfe;
}
.rt-note { font-size: 12px; color: var(--text-light); margin-top: 12px; line-height: 1.7; }
.rt-note code { font-family: var(--rt-mono); background: var(--rt-code-bg); padding: 1px 5px; border-radius: 4px; }

/* ===== 语法速查 ===== */
.rt-ref-search { margin-bottom: 12px; }
.rt-ref-search-input {
    width: 100%;
    font-family: inherit;
    font-size: 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    outline: none;
    transition: var(--transition);
}
.rt-ref-search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26, 110, 255, 0.12); }
.rt-ref-cat { margin-bottom: 16px; }
.rt-ref-cat h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.rt-ref-cat h4::before { content: ''; width: 6px; height: 6px; background: var(--primary); border-radius: 50%; }
.rt-ref-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.rt-ref-table td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    vertical-align: top;
    line-height: 1.6;
}
.rt-ref-table td:first-child {
    font-family: var(--rt-mono);
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
    cursor: pointer;
    background: var(--rt-code-bg);
}
.rt-ref-table td:first-child:hover { color: var(--primary-dark); text-decoration: underline; }
.rt-ref-table td:last-child { color: var(--text-secondary); }

/* ===== 正则库 ===== */
.rt-lib-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.rt-lib-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    transition: var(--transition);
    cursor: pointer;
}
.rt-lib-card:hover {
    border-color: rgba(26, 110, 255, 0.35);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}
.rt-lib-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.rt-lib-name { font-size: 13px; font-weight: 700; color: var(--text); }
.rt-lib-tags { display: flex; gap: 4px; margin-left: auto; }
.rt-lib-tag {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 100px;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}
.rt-lib-pattern {
    font-family: var(--rt-mono);
    font-size: 12px;
    color: var(--primary-dark);
    background: var(--rt-code-bg);
    border-radius: 6px;
    padding: 6px 10px;
    word-break: break-all;
    margin-bottom: 6px;
}
.rt-lib-desc { font-size: 12px; color: var(--text-light); line-height: 1.6; }

/* ===== 隐私说明 ===== */
.rt-privacy {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-top: 24px;
    background: linear-gradient(135deg, #e8f1ff 0%, #f0f5ff 100%);
    border: 1.5px solid rgba(26, 110, 255, 0.15);
    border-radius: var(--radius);
    padding: 18px 22px;
}
.rt-privacy-icon {
    width: 40px; height: 40px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.rt-privacy-icon svg { width: 20px; height: 20px; color: white; }
.rt-privacy strong { font-size: 14px; color: var(--text); }
.rt-privacy p { font-size: 13px; color: var(--text-secondary); line-height: 1.7; margin-top: 4px; }

/* ===== Toast ===== */
.rt-toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: white;
    font-size: 13px;
    font-weight: 500;
    padding: 10px 22px;
    border-radius: 100px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9999;
    max-width: calc(100vw - 48px);
    text-align: center;
}
.rt-toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* ============================================================
   响应式适配（工具区域）
   ============================================================ */
@media (max-width: 1024px) {
    .rt-workspace { grid-template-columns: 1fr; }
    .rt-editor-wrap { height: 340px; }
    .rt-tab-body { height: auto; max-height: 480px; }
}

@media (max-width: 768px) {
    .rt-breadcrumb { padding-top: 88px; }
    .rt-stats { grid-template-columns: repeat(2, 1fr); gap: 16px; padding: 16px; }
    .rt-stat strong { font-size: 20px; }
    .rt-pattern-bar { padding: 14px 14px 16px; }
    .rt-flag .rt-flag-desc { display: none; }
    .rt-editor-toolbar { padding: 10px 12px; }
    .rt-select { max-width: 140px; }
    .rt-editor-wrap { height: 300px; }
    .rt-highlight, .rt-textarea { font-size: 12.5px; padding: 12px; }
    .rt-tab { padding: 11px 14px; font-size: 12px; }
    .rt-tab-body { padding: 12px; }
    .rt-replace-input-row { flex-direction: column; }
    .rt-privacy { flex-direction: column; gap: 10px; padding: 16px; }
    .rt-toast { bottom: 20px; font-size: 12px; }
}

/* ============================================================
   移动端导航 / 页脚适配 —— 照抄官网首页内联 <style> 规则
   （桌面端样式由 ../../style.css 决定，此处不重写）
   ============================================================ */
@media (max-width: 1024px) {
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 72px;
        left: 0; right: 0;
        background: white;
        flex-direction: column;
        padding: 16px 24px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
        gap: 4px;
        border-bottom: 1px solid var(--border);
        z-index: 999;
    }
    .nav-links.active { display: flex; }
    .mobile-toggle { display: flex; }
    .footer-grid { grid-template-columns: 1fr; gap: 32px; }
}
