﻿:root {
    /* New Palette (Darker) */
    --bg-dark: #0a101d;
    /* Much Darker, Ink Blue */
    --bg-panel: #111b30;
    /* Deep Navy for panels */
    --bg-hover: #1a2640;
    /* Subtle lift for hover */

    --primary: #b7944b;
    /* Key Color (Gold) */

    --text-main: #ffffff;
    /* Stark White */
    --text-muted: #8b9bb4;
    /* Dimmed Blue-Grey */

    --border: #22304d;
    /* Dark Blue Border */

    --font-ui: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-mongol: 'Noto Sans Mongolian', sans-serif;
    --editor-height: calc(100vh - 180px);
}

/* Floating Actions (Universal) */
.mobile-float-actions {
    position: absolute;
    bottom: 25px;
    right: 25px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
    /* Ensure it stays above everything */
    align-items: stretch;
    /* Make all children same width */
    pointer-events: none;
    width: 190px;
    /* Reduced width for a more compact look */
}

.mobile-float-btn {
    pointer-events: auto;
    width: 100%;
    /* Fill container */
    height: 48px;
    border-radius: 8px;
    background: #18181b;
    border: 1px solid #333;
    color: #e4e4e7;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s, border-color 0.2s;
    letter-spacing: 0.02em;
}

.mobile-float-btn:hover {
    background: #27272a;
    border-color: #444;
}

.mobile-float-btn:active {
    transform: scale(0.96);
    background: #333;
}

/* Fix Mirror Pane Floating Context (Universal) */
.mirror-pane {
    position: relative;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
}

/* Global Toggle Switch Styles */
.mobile-toggle-item {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #18181b;
    border: 1px solid #333;
    padding: 5px 12px;
    border-radius: 8px;
    height: 48px;
    /* Matching button height */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
}

.mobile-toggle-item .label {
    font-size: 13px;
    font-weight: 500;
    color: #e4e4e7;
    flex: 1;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: .3s;
    border-radius: 20px;
    border: 1px solid #444;
}

.toggle-switch .slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: #aaa;
    transition: .3s;
    border-radius: 50%;
}

.toggle-switch input:checked+.slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

.toggle-switch input:checked+.slider:before {
    transform: translateX(16px);
    background-color: white;
}

/* Phone-specific sizing (approx 30% smaller) */
@media (max-width: 600px) {
    .mobile-float-actions {
        width: 140px;
        bottom: 15px;
        right: 15px;
        gap: 6px;
    }

    .mobile-float-btn,
    .mobile-toggle-item {
        height: 38px;
        padding: 0 10px;
        border-radius: 6px;
    }

    .mobile-float-btn span:first-child {
        font-size: 11px !important;
        letter-spacing: 0.2px;
    }

    .mobile-float-btn span:last-child {
        font-size: 6px !important;
    }

    .mobile-toggle-item .label {
        font-size: 11px;
    }

    .toggle-switch {
        width: 30px;
        height: 16px;
    }

    .toggle-switch .slider:before {
        height: 12px;
        width: 12px;
        left: 2px;
        bottom: 2px;
    }

    .toggle-switch input:checked+.slider:before {
        transform: translateX(14px);
    }
}

/* Hide Converter Controls on Mobile handled in media query below */

/* Editor Tool Buttons (Zoom/Pan) */
.canvas-controls {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: row;
    /* Horizontal layout for top bar */
    gap: 12px;
    z-index: 50;
    pointer-events: none;
    /* Let clicks pass through to child buttons */
}

.editor-tool-btn {
    pointer-events: auto;
    width: 40px;
    height: 40px;
    background: #1f1f23;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.editor-tool-btn:hover {
    background: #2a2a30;
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.editor-tool-btn.active {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(138, 180, 248, 0.4);
}



/* Learning Shortcut Hint Overlay */
.shortcut-hint {
    position: absolute;
    left: 50%;
    top: calc(100% + 15px);
    transform: translateX(-50%) translateY(-10px);
    background: #18181b;
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 11px;
    color: #fff;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    z-index: 2000;
}

.editor-tool-btn:hover .shortcut-hint {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.shortcut-hint::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-left-color: #18181b;
}

/* Specialized Cursors */
.panning-active {
    cursor: grab !important;
}

.panning-active:active,
.grabbing {
    cursor: grabbing !important;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-ui);
    overflow: hidden;
    display: flex;
    height: 100vh;
}

.app-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    z-index: -1;
}

.sidebar {
    width: 350px;
    min-width: 350px;
    /* Keep content solid block */
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
    overflow: visible;
    /* Allow handle to peek out */
    flex-shrink: 0;
    position: relative;
    z-index: 2000;

    /* Constraint */
    max-width: 350px;
}

/* Vertical Toggle Handle (Drawer Style) */
.sidebar-handle {
    position: absolute;
    right: -24px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 25%;
    /* 2/8 of sidebar height when open */
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: width 0.3s ease, height 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), transform 0.3s ease, right 0.3s ease, background 0.3s ease, color 0.3s ease;
    padding: 0;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.3);
    z-index: 2001;
    outline: none !important;
    /* Remove orange outline */
}

.sidebar-handle:hover {
    background: var(--bg-hover);
    color: var(--primary);
    width: 30px;
    right: -30px;
}

.handle-icon {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed .handle-icon {
    transform: rotate(180deg);
    /* Flip arrow */
}

.sidebar.collapsed .sidebar-handle {
    height: 8.3%;
    /* 3x shorter than open version */
    right: -24px;
    background: var(--bg-panel) !important;
    /* Sidebar blue BG */
    border-color: var(--border);
    color: #ffffff;
    box-shadow: none;
    transform: translateY(-50%);
    /* Attached naturally to sliding block */
}

.sidebar.collapsed {
    margin-left: -350px;
    /* Slide the whole 250px block out */
    padding: 20px;
    /* Keep padding to avoid inner jumps */
    border-right-color: transparent;
    opacity: 1;
}

.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .menu,
.sidebar.collapsed .sidebar-footer {
    opacity: 1;
    /* Keep visible while sliding off */
    pointer-events: none;
    white-space: nowrap;
    /* Prevent squishing */
}

.btn-toggle-sidebar {
    display: none;
    /* Removed in favor of handle */
}

/* Desktop Refinements */
@media (min-width: 1025px) {

    #sidebar-toggle-top,
    #sidebar-close-btn {
        display: none !important;
    }
}

.btn-toggle-sidebar:hover {
    background: #27272a;
    color: var(--primary);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
    text-decoration: none;
    color: inherit;
    white-space: nowrap;
}

.logo-icon {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    background: #1f1f23;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-family: var(--font-heading);
}

.logo h1 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 500;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    transition: 0.2s;
}

.menu-item.active {
    background: #1f2937;
    color: var(--primary);
}


/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.dev-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dev-text {
    display: flex;
    flex-direction: column;
}

.dev-text .label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dev-text .name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.dev-text .name:hover {
    color: var(--primary) !important;
}

.btn-coffee {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #ffffff;
    /* White BG */
    color: #000000;
    /* Black Text */
    border: 1px solid #ffffff;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.btn-coffee:hover {
    background: var(--primary);
    /* Gold BG */
    color: #000000;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(183, 148, 75, 0.4);
    /* Gold shadow */
}


/* UI Components */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-ui);
    gap: 8px;
    white-space: nowrap;
}

.action-btn.primary {
    background: var(--primary);
    color: #000;
}

.action-btn.primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.action-btn.secondary {
    background: #1f1f23;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.action-btn.secondary:hover {
    background: #27272a;
    border-color: var(--text-muted);
}

/* Tactile Active States */
.menu-item.active-press,
.logo.active-press,
.action-btn.active-press {
    background: var(--primary) !important;
    color: #000 !important;
    transform: translateY(1px);
    transition: none;
}

.menu-item.active-press svg {
    stroke: #000 !important;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Windowing System: Force containment */
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

.top-bar {
    height: 60px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 40px;
}

.workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-width: 0;
    /* Ensures flex children are contained */
    min-height: 0;
}

.editor-pane {
    /* Use flex-grow explicitly instead of raw flex:1 to play nice with resizing */
    flex: 1 1 0%;
    /* Basis 0 is key to the 'Window' logic */
    width: 0;
    /* Force flex to ignore content width */
    min-width: 0;
    /* IMPORTANT: Prevents expansive text from pushing sibling panes */
    background-color: #ffffff;
    /* Unified Infinite Background */
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Controls stay fixed */
}

.editor-scroll-container {
    flex: 1;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    /* Re-enabled for lower regions */
    position: relative;
    scroll-behavior: smooth;
    /* Smooth programmatic scrolling */

    /* Native way to put horizontal scrollbar at the top REMOVED -> Now standard Right/Bottom */
    /* direction: rtl; */

    /* Background moved to #main-editor for synchronized 2D zoom */


    padding: 20px 80px 10px 80px;
    /* Tighter vertical for better 'window' look */
    min-height: calc(100% - 30px);
    /* Allow flex to shrink it properly */

    /* Ensure no content can pull the container wide */
    contain: layout size;

    /* Prevent browser scroll anchoring from jumping around during text entry */
    overflow-anchor: none;
}

/* Premium Scrollbar for the Scroll Container */
.editor-scroll-container::-webkit-scrollbar {
    height: 14px;
    /* Horizontal */
    width: 12px;
    /* Vertical - thicker for accessibility */
}

.editor-scroll-container::-webkit-scrollbar-track {
    background: rgba(138, 180, 248, 0.1);
    /* Visible blue-tinted track */
    border-radius: 10px;
}

.editor-scroll-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    /* Signature Blue */
    border-radius: 10px;
    border: 3px solid #ffffff;
    box-shadow: 0 0 10px rgba(138, 180, 248, 0.3);
}

.editor-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #6D9AEA;
    /* Slightly darker blue on hover */
}

.resizer {
    width: 6px;
    background: var(--bg-dark);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    cursor: col-resize;
    transition: background 0.2s;
    z-index: 10;
}

.resizer:hover,
.resizer.dragging {
    background: var(--primary);
}

.mirror-pane {
    width: 50%;
    /* Start in the middle */
    /* Initial Split width */
    flex: 0 0 50%;
    /* Strict basis for 'Window' logic */
    min-width: 0;
    /* Prevents overflow pushing */
    background: #000;
    /* Full Black */
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    /* Safety constraint */
    max-width: 90%;
}

.pane-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 15px;
    height: 20px;
    /* Fixed height for calc */
    display: block;
}

#main-editor {
    /* Height based on content to avoid empty white space below */
    min-height: calc(100% - 30px);
    width: 100%;
    background-color: #ffffff;
    background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.08) 1px, transparent 1px);
    background-size: 46px 46px;
    /* Adjust the first value (X-axis) to shift dots left/right */
    background-position: 0px 0px;
    background-attachment: local;
    color: #000000 !important;
    border: none;
    outline: none;
    resize: none;

    /* Document direction reset to prevent text flip from container's rtl */
    direction: ltr;

    /* Vertical-LR */
    writing-mode: vertical-lr;
    text-orientation: mixed;
    font-family: var(--font-mongol);
    font-size: 26px;
    line-height: 46px;
    /* Remove default padding to ensure text spine aligns exactly with background dots */
    padding: 5px;

    /* Disable internal scrollbars so we use the parent container's premium ones */
    overflow: hidden;
}

#main-editor:focus {
    /* No shadow/background change on focus to keep canvas clean */
    outline: none;
}

/* Custom Scrollbar for Classical Editor (Process-like) */
#main-editor::-webkit-scrollbar {
    height: 8px;
    /* Horizontal scroll since it's vertical text */
    width: 8px;
}

#main-editor::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
}

#main-editor::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

#main-editor::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

#main-editor::placeholder {
    color: rgba(0, 0, 0, 0.15);
    font-family: var(--font-mongol);
}

#main-editor::selection {
    background: rgba(183, 148, 75, 0.25);
    /* Subtle gold tint */
    color: var(--primary);
}

#main-editor::-moz-selection {
    background: rgba(183, 148, 75, 0.25);
    color: var(--primary);
}

.cyrillic-display {
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    line-height: 1.6;
    color: #fff;
    /* White text */
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    flex: 1;
    /* Fill space */
    white-space: pre-wrap;
}

#cyrillic-output::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

#cyrillic-output::selection {
    background: rgba(183, 148, 75, 0.25);
    color: var(--primary);
}

#cyrillic-output::-moz-selection {
    background: rgba(183, 148, 75, 0.25);
    color: var(--primary);
}

.status-bar {
    height: 40px;
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 30px;
    font-size: 13px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.label {
    color: var(--text-muted);
}

.val-mongol {
    font-family: var(--font-mongol);
    font-size: 18px;
    color: var(--primary);
}

.val-std {
    color: var(--text-main);
    font-weight: 600;
}

.toggle-group {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-muted);
}

/* Floating Modern Tooltip */
.typing-balloon {
    position: absolute;
    padding: 6px 10px;
    border-radius: 10px;
    background: var(--bg-hover);
    /* Themed Dark Navy */
    border: 1px solid var(--primary);
    /* Gold Border */
    box-shadow: 0 8px 32px rgba(183, 148, 75, 0.4);
    /* Gold Glow */

    color: var(--primary);
    /* Gold Text */
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    white-space: pre;
    z-index: 1000;

    opacity: 0;
    pointer-events: none;
    /* Ignore mouse events so it doesn't flicker */
    transform: translate(10px, 10px);
    /* smooth floaty movement */
    transition: opacity 0.2s ease, transform 0.1s ease-out, top 0.1s linear, left 0.1s linear;

    /* Layout */
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 40px;
}

.b-cyr {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.b-lat {
    font-size: 10px;
    font-weight: 500;
    opacity: 0.5;
    text-transform: uppercase;
    margin-top: -2px;
}

.typing-balloon.visible {
    opacity: 1;
    transform: translate(15px, 15px);
    /* Steady state offset */
}

/* Vertical Spelling List */
.b-spelling {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 0;
}

.b-char-row {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    text-transform: lowercase;
}

.b-selected-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 5px;
    border-bottom: 1px solid var(--border);
    width: 100%;
    text-align: center;
    padding-bottom: 2px;
}


/* Panel Toggle Bar (Handle) */
.panel-toggle-bar {
    position: relative;
    height: 0;
    width: 100%;
    z-index: 200;
    display: flex;
    justify-content: center;
    pointer-events: none;
    /* Let clicks pass through empty space */
}

.toggle-pill-btn {
    background: #1F1F23;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-top: none;
    /* Look like it's coming from above if open, or below if closed? Let's just make it a pill */
    border-radius: 20px;
    /* Pill */
    padding: 6px 26px;
    /* Scaled down 80% */
    cursor: pointer;
    border-top: 1px solid var(--border);
    /* Ensure full border for solid look */
    pointer-events: auto;
    /* Re-enable clicks */
    transform: translateY(-50%);
    /* Center on the line */
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    z-index: 201;
    /* Ensure it sits above the line */
}

.toggle-pill-btn svg {
    width: 20px;
    height: 20px;
}

.toggle-pill-btn:hover {
    color: var(--primary);
    background: #2A2A30;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
    border-color: rgba(138, 180, 248, 0.3);
}

.toggle-pill-btn.active svg {
    transform: rotate(180deg);
    /* Flip chevron if active/open */
    transition: transform 0.3s;
}

.toggle-pill-btn:not(.active) svg {
    transform: rotate(0deg);
    transition: transform 0.3s;
}

/* Modal Overlay (Non-blocking now) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    /* Remove background and blocking */
    background: transparent;
    backdrop-filter: none;
    z-index: 2000;
    opacity: 1;
    /* Always 'active' technically, visibility controlled by content opacity/display */
    pointer-events: none;
}

.modal-overlay.active .modal-content {
    display: flex;
    /* Show it */
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

/* Modal Content (Floating Window) */
.modal-content {
    /* Fixed starting position, moved by JS */
    position: fixed;
    top: 20%;
    left: 30%;

    background: var(--bg-dark);
    /* Themed Dark BG */
    border: 1px solid var(--border);
    border-radius: 12px;

    width: 400px;
    height: 500px;
    min-width: 250px;
    min-height: 200px;

    display: none;
    /* Hidden by default */
    opacity: 0;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;

    /* Resizable */
    resize: both;
    overflow: hidden;
    /* For resize handle to show on some browsers and contain content */
}

.modal-header {
    padding: 15px;
    background: var(--bg-panel);
    /* Themed Panel Header */
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    /* Draggable handle */
    user-select: none;
}

.modal-header:active {
    cursor: grabbing;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-main);
    pointer-events: none;
    /* Don't interfere with drag? actually fine */
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.close-btn:hover {
    color: #fff;
    background: #27272a;
    border-radius: 4px;
}

.modal-body {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
    /* Fill remaining space */
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* Keymap Grid */
.keymap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
}

.key-card {
    background: var(--bg-dark);
    /* Inverted: Darker than panel */
    /* Themed */
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: 1px solid transparent;
    transition: 0.2s;
}

.key-card:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
    /* Themed hover */
}

.k-mongol {
    font-family: var(--font-mongol);
    font-size: 24px;
    color: var(--text-main);
    writing-mode: vertical-lr;
    height: 40px;
    /* Fixed height for consistent look */
    display: flex;
    align-items: center;
    justify-content: center;
}

.k-cyr {
    font-size: 14px;
    color: var(--primary);
    /* Swapped to Gold */
    font-weight: 600;
}

.k-phonetic {
    font-size: 12px;
    color: var(--text-muted);
    /* Swapped to Muted */
    text-transform: uppercase;
}

/* Syllable Hover Tooltip */
#vk-hover-tooltip {
    display: flex;
    position: absolute;
    z-index: 2100;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.7), 0 0 20px rgba(183, 148, 75, 0.1);
    font-family: var(--font-mongol);
    transition: opacity 0.25s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    opacity: 0;
    transform: translateY(5px);
    min-width: fit-content;
}

#vk-hover-tooltip.sticky {
    pointer-events: auto;
    border-color: var(--primary);
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.8), 0 0 30px rgba(183, 148, 75, 0.2);
}

.vk-tooltip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
    gap: 10px;
    width: 100%;
    min-width: 220px;
}

.vk-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#vk-hover-tooltip.sticky .vk-opt {
    cursor: pointer;
}

#vk-hover-tooltip.sticky .vk-opt:hover {
    background: var(--bg-hover);
    border-color: rgba(183, 148, 75, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}

.vk-opt-mongol {
    font-size: 32px;
    color: var(--text-main);
    writing-mode: vertical-lr;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
    transition: color 0.2s ease;
}

.vk-opt:hover .vk-opt-mongol {
    color: var(--primary);
}

.vk-opt-label {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-weight: 600;
    letter-spacing: 0.8px;
}

.vk-opt:hover .vk-opt-label {
    color: var(--text-main);
}

/* ============================
   RESPONSIVE (TABLET/MOBILE) STYLES
   ============================ */

@media (max-width: 1024px) {

    /* Main Layout - Stack Vertical */
    html,
    body {
        overscroll-behavior: none;
        /* Prevent rubber-banding */
        position: fixed;
        /* Nuclear option to lock body scroll on iOS */
        width: 100%;
        height: 100%;
        overflow: hidden;
        /* Ensure body doesn't scroll */
    }

    body {
        flex-direction: column;
        height: 100dvh;
        /* Use dynamic viewport height for mobile browsers */
        /* overflow: hidden; */
        /* Prevent body scroll, everything inner scrolls - moved to html, body */
    }

    .content-area {
        height: 100%;
        /* Ensure content area fills body height */
        overflow: hidden;
        /* Ensure content area doesn't overflow */
        display: flex;
        flex-direction: column;
    }

    /* Collapse Sidebar by default */
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 350px;
        /* Locked to default width */
        z-index: 2000;
        box-shadow: 5px 0 20px rgba(0, 0, 0, 0.5);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        /* Override Desktop Collapsed Props override */
        opacity: 1;
        padding: 20px;
    }

    .sidebar.collapsed {
        left: -350px;
        width: 350px;
        /* Keep fixed width to anchor handle */
        margin-left: 0;
        min-width: 0;
        background: var(--bg-panel);
        opacity: 1;
        box-shadow: none;
    }

    /* Reset desktop translateX for mobile handle */
    .sidebar.collapsed .sidebar-handle {
        transform: translateY(-50%) translateX(0);
    }

    /* Workspace - Side-by-Side (Vertical Split) on Mobile */
    .workspace {
        flex-direction: row;
        /* Side by Side instead of Column */
        flex: 1;
        /* Allow workspace to grow/shrink */
        height: auto;
        /* Let flexbox determine height */
        min-height: 0;
        /* CRITICAL: Allows flex child to have percentage height */
        max-height: none;
        /* Remove fixed max-height, let flexbox manage */
        overflow: hidden;
    }

    /* Resizer - Vertical Splitter */
    .resizer {
        width: 6px;
        height: 100%;
        border-top: none;
        border-bottom: none;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
        cursor: col-resize;
        flex-shrink: 0;
        display: block !important;
        /* Force visible */
    }

    .editor-pane {
        width: auto !important;
        flex: 1 1 50%;
        /* Strict 50% split */
        height: 100% !important;
        border-right: none;
        overflow-x: auto;
        padding: 10px;
        /* Disable smooth scroll on mobile to prevent fighting with JS/Native */
        scroll-behavior: auto !important;
    }

    #main-editor {
        /* Also disable anchoring on the textarea itself */
        overflow-anchor: none;
        height: 100%;
        min-height: 0;
        min-width: 100%;
        padding: 0;
    }

    .mirror-pane {
        width: auto !important;
        flex: 1 1 50%;
        /* Strict 50% split */
        height: 100% !important;
        padding: 10px;
        overflow-y: auto;
    }

    .top-bar {
        padding: 0 10px;
        height: 80px;
        /* Adjusted for larger logo */
        flex-shrink: 0;
        justify-content: center;
        /* Center the logo */
        position: relative;
        /* For absolute positioning of toggle btn if needed */
    }

    .logo h1 {
        font-size: 1rem;
        /* Compact logo text */
    }


    .status-bar {
        display: none;
        /* Often too cluttered for mobile, or simplify it */
    }

    /* Hide Smart Input on Mobile */
    .smart-toggle-container {
        display: none !important;
    }

    /* Hide Top Header Actions on Mobile */
    #top-bar-actions {
        display: none !important;
    }

    /* Hide Canvas Controls (Zoom/Pan) on mobile to clear bottom right */
    .canvas-controls {
        display: none !important;
    }





    /* Scroll the text area instead */
    .mirror-pane textarea {
        flex: 1;
        overflow-y: auto;
    }

    /* Ensure Bottom Area is visible and on top */
    #bottom-area {
        flex: 0 0 auto;
        /* Stop shrinking, stop growing beyond content */
        max-height: 50vh;
        /* Safety Cap */
        z-index: 100 !important;
        position: relative;
        background: var(--bg-main);
        /* Ensure opaque background */
    }

    /* Ensure Ad Space is active */
    /* Ensure Ad Space is active */
    #right-panel-ad {
        min-height: 60px;
    }

    /* Enable Tooltip on Mobile for Long-Press */
    #vk-hover-tooltip {
        display: block;
        opacity: 0;
        /* Start hidden, JS will show it */
        pointer-events: auto !important;
        z-index: 3000 !important;
        /* Above sidebar (2000) */
    }

    #typing-balloon {
        display: none !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

}