Generate an advanced python script that envelops this idea with a GUI:

```
---

# Modular Keycase Reverse(/) Algorithm

**Complexity Level**: Advanced  
**Layers**: Puzzle Layering (2x)  
**Difficulty Rating**: 8x  

---

## Overview of Modular Keycase Reverse(/)

The **Modular Keycase Reverse(/)** algorithm is a multi-layered, complex cipher designed with multiple obfuscation steps inspired by classical Caesar ciphers and modern encryption techniques (like AES) for a challenging and secure encoding process. This algorithm uses modular arithmetic, case manipulation, and reverse transformations to encode messages with a high level of difficulty. Each layer must be carefully reversed during decryption.

---

### Key Elements

1. **Key Phrase**: User-provided string (e.g., "OBSCURE").
2. **Modulo Base (N)**: A numeric value derived from the key phrase, influencing modular operations.
3. **Case Mask**: Binary representation of each letter's case.
4. **Reverse Pass**: Two-pass reversal operation based on a modular rule.

---

### Encoding Process

#### Step 1: Key Phrase Modulo Calculation
   - Convert each letter in the key phrase to its alphabetical position (A=1, B=2, ..., Z=26).
   - Sum these values to derive the **Modulo Base (N)**.
   - Example: For "OBSCURE" (15 + 2 + 19 + 3 + 21 + 18 + 5) = 83, then use **N = 83 % 26 = 5**.

#### Step 2: Modular Shift
   - For each letter in the message, shift its position **forward by N** (from Step 1) if it’s uppercase or **backward by N** if it’s lowercase.
   - Wrap around alphabetically if the shift exceeds "Z" or goes below "A" for uppercase, or below "a" for lowercase.
   - Example:
      - Original: **"HeLLo"**
      - Modular Base (N = 5)
      - Encoded: **"MjQQt"**

#### Step 3: Apply Case Mask
   - Record the **binary case** (1 for uppercase, 0 for lowercase) for each letter.
   - Generate a **Case Mask String** by joining binary values, e.g., for "HeLLo" => "10110".
   - Attach the Case Mask as a suffix to the shifted text.
   - Encoded so far: **"MjQQt/10110"**

#### Step 4: Reverse by Modular Segments
   - Reverse the text in segments determined by **Modulo Base (N)**.
   - Segment the encoded text (excluding the case mask) into groups of size **N**.
   - Reverse each segment independently.
   - Example:
      - Text without case mask: "MjQQt"
      - Segmented into "MjQ" and "Qt" (using N=3).
      - Reverse each: "QjM" and "tQ".
      - Combine and add the case mask back: **"QjMtQ/10110"**

#### Step 5: Second Pass Reverse
   - Reverse the entire string, including the case mask, for an additional layer.
   - Example:
      - Reverse "QjMtQ/10110" to get **"01101/QMtjQ"**

---

### Final Encoded Output

After completing the above steps, the **final encoded message** is presented in the format:

```
<Reversed Encoded Text>/<Reversed Case Mask>
```

For example, given "HeLLo" with the key "OBSCURE", the output might be:

**"01101/QMtjQ"**

---

## Decoding Process

To decode, follow these steps in reverse order:

1. **Second Pass Reverse**: Reverse the entire string to restore it to **Step 4’s output**.
2. **Segment Reverse**: Reverse each modular segment of the text to restore **Step 3’s output**.
3. **Remove Case Mask**: Separate the encoded message and case mask.
4. **Apply Modular Unshift**: Reverse the modular shift, using **Modulo Base (N)**.
5. **Restore Original Case**: Use the Case Mask to convert each letter back to its original case.