/* 1. SPELLCHECK HIGHLIGHTING (Restored) */
::highlight(mermru-error) {
    text-decoration: underline wavy #ff4444;
    text-decoration-thickness: 2px;
}

/* 2. GLOBAL & BASE STYLES */
html, body {
    margin: 0; padding: 0;
    height: 100%; width: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', sans-serif;
}

/* 3. MOBILE-FIRST LAYOUT (Default: Grid at Top) */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

.fidel-sidebar {
    width: 100%;
    height: 220px;
    background: #f1f3f4;
    border-bottom: 1px solid #ccc;
    overflow-y: auto;
    flex-shrink: 0; /* Prevents keyboard from squishing grid */
}

.fidel-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    padding: 10px;
}

.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    min-height: 0;
}

#mermru-main-editor {
    flex: 1;
    padding: 20px;
    font-size: 1.4rem;
    outline: none;
    overflow-y: auto;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* 4. DESKTOP OVERRIDE (Width > 768px: Side-by-Side) */
@media (min-width: 769px) {
    .app-layout {
        flex-direction: row;
    }
    .fidel-sidebar {
        width: 350px;
        height: 100vh;
        border-bottom: none;
        border-right: 1px solid #ccc;
    }
    .fidel-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    #mermru-main-editor {
        padding: 40px;
        font-size: 1.8rem;
    }
}

#ghost-suggestion {
    color: rgba(0, 0, 0, 0.3); /* Light grey / Transparent */
    pointer-events: none;      /* User can't click it */
    user-select: none;         /* User can't select it */
}

.mermru-ghost {
    color: #afafaf;
    pointer-events: none;
    user-select: none;
    position: absolute;
    white-space: pre;
    font-family: inherit;
}

/* 5. FIDEL KEYS & UI ELEMENTS */
.fidel-key {
    aspect-ratio: 1/1;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    position: relative;
    user-select: none;
}

.fidel-key::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 3px;
    height: 3px;
    background: #bbb;
    border-radius: 50%;
}

.variation-popup, #mermru-suggestion-box {
    position: fixed;
    display: none;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border: 1px solid #ccc;
    z-index: 9999;
}

.variation-btn {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    user-select: none;
}

#mermru-suggestion-bar button {
    background: white;
    border: 1px solid #ccc;
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 14px;
    color: #333;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    cursor: pointer;
}
#mermru-suggestion-bar button:active {
    background: #e0e0e0;
}

#mermru-suggestion-box {
    position: fixed; /* Keep it relative to the screen, not the editor */
    background: white;
    border: 1px solid #ccc;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    z-index: 9999;
    overflow: hidden;
    transition: opacity 0.2s ease-in-out;
    font-family: inherit;
}

.variation-btn:hover {
    background: #3498db;
    color: white;
    border-radius: 4px;
}


#mermru-suggestion-bar button {
    background: white;
    border: 1px solid #ccc;
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 14px;
    cursor: pointer;
}

#mermru-ghost-element {
    /* These ensure the ghost doesn't interfere with the editor */
    position: absolute;
    pointer-events: none;
    white-space: pre;
    display: none;
    color: rgba(0,0,0,0.3);

    /* THE MAC DEV NUDGE */
    /* Because you are on a Mac, the font sits 'low' in the line box. */
    /* We push the element down by a few pixels to align the baselines. */
    padding-top: 5px;

    /* Ensure the line-height doesn't fight the nudge */
    line-height: normal;
}

/* --- 📱 LANDSCAPE OPTIMIZATION --- */
@media (max-width: 900px) and (orientation: landscape) {
    .fidel-sidebar {
        height: 120px !important; /* Shorter grid to save space */
    }

    .fidel-grid {
        grid-template-columns: repeat(12, 1fr) !important; /* More columns, smaller keys */
        gap: 4px !important;
        padding: 5px !important;
    }

    .editor-area {
        height: calc(100vh - 120px) !important;
    }

    #mermru-main-editor {
        padding: 10px 20px !important;
        font-size: 1.2rem !important; /* Smaller text to see more lines */
    }
}
