* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --accent: #06b6d4;
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.85);
    --bg-input: rgba(15, 23, 42, 0.5);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(148, 163, 184, 0.12);
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.4;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 0;
}

/* 头部 */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 12px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 主布局 */
.main-layout {
    display: flex;
    gap: 16px;
    height: calc(100vh - 130px);
    min-height: 500px;
    width: 100%;
}

/* 左侧面板 */
.left-panel {
    width: 450px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* 标签导航 */
.tab-nav {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 10px;
}

.tab-nav .tab-btn {
    flex: 1;
    padding: 8px 4px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.tab-nav .tab-btn .icon {
    font-size: 1rem;
}

.tab-nav .tab-btn:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
}

.tab-nav .tab-btn.active {
    background: var(--primary);
    color: white;
}

/* 配置面板 */
.config-panel {
    flex: 1;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.config-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    padding-bottom: 16px;
    min-height: 0;
}

.tab-section {
    display: none;
}

.tab-section.active {
    display: block;
}

/* 表单元素 */
.form-group {
    margin-bottom: 8px;
}

.form-group label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.form-control {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.75rem;
    background: var(--bg-input);
    color: var(--text-primary);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' fill='%2394a3b8'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
    cursor: pointer;
}

input[type="number"] {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.75rem;
    background: var(--bg-input);
    color: var(--text-primary);
}

.hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}

textarea.form-control {
    resize: vertical;
    min-height: 60px;
    font-family: monospace;
}

/* 开关 */
.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg-input);
    border-radius: 6px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-group:hover {
    background: rgba(99, 102, 241, 0.08);
}

.toggle-group.active {
    background: rgba(99, 102, 241, 0.12);
}

.toggle-info {
    flex: 1;
}

.toggle-title {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
}

.toggle-desc {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.toggle-switch {
    width: 32px;
    height: 18px;
    background: rgba(100, 116, 139, 0.3);
    border-radius: 9px;
    position: relative;
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: all 0.2s;
}

.toggle-group.active .toggle-switch {
    background: var(--primary);
}

.toggle-group.active .toggle-switch::after {
    left: 16px;
}

/* 功能区 */
.feature-section {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border);
}

.feature-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.feature-section h3 {
    font-size: 0.7rem;
    color: var(--accent);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 规则列表 */
.rule-item {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    background: var(--bg-input);
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 0.7rem;
}

.rule-type {
    color: var(--accent);
    font-weight: 600;
    margin-right: 6px;
}

.rule-path {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.delete-btn {
    padding: 2px 6px;
    background: rgba(239, 68, 68, 0.1);
    border: none;
    border-radius: 3px;
    color: #ef4444;
    cursor: pointer;
    font-size: 0.65rem;
}

/* 按钮 */
.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--primary);
    color: white;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--primary-dark);
}

/* 复选框 */
input[type="checkbox"] {
    appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    background: var(--bg-input);
}

input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

input[type="checkbox"]:checked::after {
    content: '✓';
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 9px;
}

/* 警告框 */
.alert {
    padding: 6px 10px;
    border-radius: 5px;
    margin-bottom: 8px;
    font-size: 0.7rem;
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.2);
    color: #22d3ee;
}

/* 模板 */
.quick-templates {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.quick-templates h3 {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.template-btn {
    position: relative;
    padding: 8px 4px;
    background: linear-gradient(135deg, var(--bg-input), rgba(99, 102, 241, 0.1));
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.template-btn .t-icon {
    font-size: 1.1rem;
    transition: transform 0.25s;
}

.template-btn:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.template-btn:hover .t-icon {
    transform: scale(1.2);
}

.template-btn:active {
    transform: translateY(-1px) scale(0.98);
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.4);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-icon {
    width: 20px;
    height: 20px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

/* 右侧代码面板 */
.right-panel {
    flex: 1;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(22, 27, 34, 0.5);
    border-bottom: 1px solid var(--border);
}

.code-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot:nth-child(1) { background: #ff5f56; }
.dot:nth-child(2) { background: #ffbd2e; }
.dot:nth-child(3) { background: #27c93f; }

.code-actions {
    display: flex;
    gap: 6px;
}

.copy-btn {
    padding: 5px 10px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: rgba(99, 102, 241, 0.25);
}

.copy-btn.copied {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.copy-btn.download {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.2);
}

.copy-btn.download:hover {
    background: rgba(16, 185, 129, 0.25);
}

.code-body {
    flex: 1;
    overflow: auto;
    padding: 10px 14px;
    background: #0d1117;
}

.code-body pre {
    margin: 0;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
}

.code-body .line {
    display: flex;
    padding: 1px 0;
}

.code-body .line:hover {
    background: rgba(99, 102, 241, 0.05);
}

.code-body .line-number {
    color: rgba(139, 92, 246, 0.35);
    min-width: 36px;
    padding-right: 12px;
    text-align: right;
    user-select: none;
    font-size: 0.7rem;
}

.code-body .line-content {
    flex: 1;
}

.code-body .comment { color: #8b949e; }
.code-body .directive { color: #7ee787; }
.code-body .value { color: #79c0ff; }
.code-body .flag { color: #ff7b72; }
.code-body .condition { color: #d2a8ff; }

/* 滚动条 */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.4);
}

/* 页脚 */
.footer {
    margin-top: 16px;
    padding: 16px 0;
    border-top: 1px solid var(--border);
    text-align: center;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.friend-links {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.friend-links-title {
    font-size: 0.6rem;
    color: var(--text-muted);
}

.friend-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.6rem;
    padding: 2px 6px;
    transition: all 0.2s;
}

.friend-links a:hover {
    color: var(--primary);
}

.footer-info {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.footer-info p {
    margin-bottom: 4px;
}

.footer-info .beian {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.footer-info .beian a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-info .beian a:hover {
    color: var(--primary);
}

.footer-info .beian::before {
    content: '📋';
    font-size: 0.8rem;
}

/* 响应式 */
@media (max-width: 1200px) {
    .container {
        max-width: 100%;
    }
}

@media (max-width: 1024px) {
    .main-layout {
        flex-direction: column;
        height: auto;
    }
    
    .left-panel {
        width: 100%;
    }
    
    .config-panel {
        max-height: 400px;
    }
    
    .right-panel {
        min-height: 400px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }
    
    .tab-nav .tab-btn {
        padding: 6px 2px;
        font-size: 0.65rem;
    }
    
    .tab-nav .tab-btn .icon {
        font-size: 0.9rem;
    }
    
    .template-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .footer-links {
        flex-wrap: wrap;
        gap: 8px;
    }
}
