* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 960px;
    margin: 0 auto;
}

/* 代码编辑器 */
.code-editor {
    position: relative;
    width: 100%;
    height: 60vh;
    min-height: 300px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #2a2a3e;
    background: #282c34;
}

.code-editor .highlight-layer,
.code-editor .input-layer {
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.6;
    padding: 16px;
    margin: 0;
    border: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-all;
    tab-size: 4;
    -moz-tab-size: 4;
}

.highlight-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
    pointer-events: none;
    color: #abb2bf;
}

.highlight-layer code {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    background: transparent !important;
    padding: 0 !important;
}

.input-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    z-index: 2;
    resize: none;
    outline: none;
    color: transparent;
    caret-color: #528bff;
    background: transparent;
    border-radius: 10px;
}

.input-layer::placeholder {
    color: #555;
}

/* 方案栏 */
.scheme-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.scheme-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.scheme-tag {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #3a3a4e;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}

.scheme-tag:hover {
    border-color: #5a5a7e;
    color: #ddd;
}

.scheme-tag.active {
    background: #3a5afe;
    border-color: #3a5afe;
    color: #fff;
}

.tag-name {
    pointer-events: none;
}

.tag-actions {
    display: none;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
}

.scheme-tag:hover .tag-actions {
    display: inline-flex;
}

.tag-actions button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0 2px;
    font-size: 14px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
    font-family: inherit;
}

.tag-actions button:hover {
    opacity: 1;
}

.scheme-tag.active .tag-actions button {
    color: rgba(255, 255, 255, 0.8);
}

.add-scheme-btn {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px dashed #4a4a5e;
    background: transparent;
    color: #888;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}

.add-scheme-btn:hover {
    border-color: #3a5afe;
    color: #3a5afe;
}

/* 弹窗 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    position: relative;
    background: #1e1e30;
    border: 1px solid #2a2a3e;
    border-radius: 14px;
    padding: 28px;
    width: 90%;
    max-width: 520px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal h3 {
    margin-bottom: 22px;
    font-size: 17px;
    font-weight: 600;
    color: #eee;
}

.btn-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #999;
    transition: all 0.15s;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #999;
}

.form-group input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #3a3a4e;
    border-radius: 8px;
    background: #14141f;
    color: #eee;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus {
    border-color: #3a5afe;
}

.rules-label {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    color: #999;
}

.rules-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.rule-item {
    display: flex;
    gap: 6px;
    align-items: center;
    background: #14141f;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #2a2a3e;
}

.rule-item select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding: 5px 22px 5px 8px;
    border: 1px solid #3a3a4e;
    border-radius: 5px;
    background: #1e1e30 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E") no-repeat right 8px center;
    color: #ccc;
    font-size: 12px;
    outline: none;
    cursor: pointer;
    font-family: inherit;
}

.rule-item input {
    flex: 1;
    min-width: 0;
    padding: 5px 8px;
    border: 1px solid #3a3a4e;
    border-radius: 5px;
    background: #1e1e30;
    color: #eee;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.rule-item input:focus {
    border-color: #3a5afe;
}

.rule-item input.flags-input {
    flex: none;
    width: 46px;
    text-align: center;
}

.rule-item .btn-delete-rule {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: #666;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.rule-item .btn-delete-rule:hover {
    background: #ff4757;
    color: #fff;
}

.add-rule-btn {
    width: 100%;
    padding: 8px;
    border: 1px dashed #3a3a4e;
    border-radius: 8px;
    background: transparent;
    color: #777;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    font-family: inherit;
}

.add-rule-btn:hover {
    border-color: #3a5afe;
    color: #3a5afe;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 22px;
}

.btn-cancel,
.btn-save {
    padding: 9px 22px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    transition: opacity 0.2s;
}

.btn-cancel {
    background: #2a2a3e;
    color: #aaa;
}

.btn-save {
    background: #3a5afe;
    color: #fff;
}

.btn-cancel:hover,
.btn-save:hover {
    opacity: 0.85;
}

/* Toast */
.toast {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #3a5afe;
    color: #fff;
    padding: 10px 26px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 200;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 滚动条 */
.code-editor textarea::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.code-editor textarea::-webkit-scrollbar-track {
    background: transparent;
}

.code-editor textarea::-webkit-scrollbar-thumb {
    background: #3a3a4e;
    border-radius: 4px;
}

.code-editor textarea::-webkit-scrollbar-thumb:hover {
    background: #4a4a5e;
}

.modal::-webkit-scrollbar {
    width: 6px;
}

.modal::-webkit-scrollbar-track {
    background: transparent;
}

.modal::-webkit-scrollbar-thumb {
    background: #3a3a4e;
    border-radius: 3px;
}

/* 响应式 */
@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    .code-editor {
        height: 50vh;
    }

    .modal {
        padding: 20px;
        margin: 12px;
    }

    .rule-item {
        flex-wrap: wrap;
    }

    .rule-item input {
        min-width: 80px;
    }
}
