/* ========================================================
   HOCNHANHTN EDITOR STUDIO - DEDICATED STYLESHEET
   ======================================================== */

:root {
    --studio-bg: #f8fafc;
    --studio-surface: #ffffff;
    --studio-border: #e2e8f0;
    --studio-text: #0f172a;
    --studio-text-muted: #64748b;
    --studio-primary: #2563eb;
    --studio-primary-hover: #1d4ed8;
    --studio-purple: #9333ea;
    --studio-purple-hover: #7e22ce;
    --studio-success: #10b981;
    --studio-danger: #ef4444;
}

body.studio-body {
    background-color: var(--studio-bg);
    color: var(--studio-text);
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
}

/* ========================================================
   REMIX ICON MODERN STYLING & MICRO-INTERACTIONS
   ======================================================== */
i[class^="ri-"], i[class*=" ri-"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: -0.15em;
    line-height: 1;
    font-size: 1.12em;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.15s ease;
}

button:hover i[class^="ri-"], button:hover i[class*=" ri-"],
.studio-back-btn:hover i[class^="ri-"] {
    transform: scale(1.15);
}

.studio-back-btn:hover i.ri-arrow-left-line {
    transform: translateX(-3px);
}

.btn-studio-ai:hover i.ri-sparkling-fill {
    transform: rotate(18deg) scale(1.22);
}

.btn-studio-primary:hover i.ri-send-plane-fill {
    transform: translate(2px, -2px) scale(1.15);
}

/* --- THANH ĐIỀU HƯỚNG STUDIO (TOP NAVBAR) --- */
.studio-navbar {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--studio-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 8px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    min-height: 56px;
    box-sizing: border-box;
}

.studio-nav-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
}

.studio-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 12px;
    background: #f8fafc;
    border: 1px solid var(--studio-border);
    border-radius: 8px;
    color: var(--studio-text);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.studio-back-btn:hover {
    background: #f1f5f9;
    color: var(--studio-primary);
    border-color: #cbd5e1;
}

.studio-back-btn.studio-discard-btn {
    color: #ef4444;
    border-color: #fecaca;
    background: #fff5f5;
}

.studio-back-btn.studio-discard-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

.studio-brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.92rem;
    color: #ffffff;
    background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
    padding: 6px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.22);
    white-space: nowrap;
    flex-shrink: 0;
    user-select: none;
}

.studio-brand-logo {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    object-fit: contain;
    background: #ffffff;
    padding: 2px;
    box-sizing: border-box;
    display: block;
    flex-shrink: 0;
}

.studio-brand-text {
    white-space: nowrap;
    font-weight: 700;
}

.studio-title-box {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 240px;
    min-width: 130px;
    max-width: 460px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 3px 8px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.studio-title-box:focus-within {
    background: #ffffff;
    border-color: var(--studio-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.studio-title-input {
    flex: 1 1 60px;
    min-width: 50px;
    width: 0;
    border: none;
    background: transparent;
    padding: 3px 4px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--studio-text);
    outline: none;
    font-family: inherit;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.studio-title-input::placeholder {
    color: #94a3b8;
    font-weight: 500;
}

.studio-badge {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    background: #eff6ff;
    color: var(--studio-primary);
    border: 1px solid #bfdbfe;
    white-space: nowrap;
    flex-shrink: 0;
}

.studio-autosave {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--studio-success);
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 2px 6px;
    background: #f0fdf4;
    border-radius: 6px;
    border: 1px solid #bbf7d0;
}

.studio-nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* --- SEGMENTED MODE SWITCHER --- */
.studio-mode-pill-group {
    display: inline-flex;
    align-items: center;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--studio-border);
    flex-shrink: 0;
}

.studio-mode-pill {
    padding: 5px 11px;
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--studio-text-muted);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.studio-mode-pill:hover {
    color: var(--studio-text);
}

.studio-mode-pill.active {
    background: #ffffff;
    color: var(--studio-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* --- ACTION BUTTONS --- */
.btn-studio-primary {
    background: var(--studio-primary);
    color: #ffffff;
    padding: 7px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.86rem;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-studio-primary:hover {
    background: var(--studio-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

#btnOpenPublishMobile,
.studio-mobile-publish-btn {
    display: none !important;
}

.studio-desktop-publish-btn {
    display: inline-flex;
}

.btn-studio-ai {
    background: #faf5ff;
    color: var(--studio-purple);
    border: 1px solid #d8b4fe;
    padding: 7px 13px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.86rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-studio-ai:hover {
    background: #f3e8ff;
    border-color: var(--studio-purple);
}

.btn-studio-outline {
    background: #ffffff;
    color: var(--studio-text-muted);
    border: 1px solid var(--studio-border);
    padding: 7px 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.86rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-studio-outline:hover {
    background: #f8fafc;
    color: var(--studio-text);
    border-color: #cbd5e1;
}

/* --- WORKSPACE CONTAINER --- */
.studio-workspace {
    max-width: 1650px;
    margin: 0 auto;
    padding: 16px 24px;
}

/* --- SPLIT LAYOUT CHO BIÊN TẬP --- */
.studio-split-layout {
    display: flex;
    gap: 20px;
    align-items: stretch;
    height: calc(100vh - 95px);
    min-height: 550px;
}

.studio-pane {
    flex: 1;
    width: 50%;
    background: var(--studio-surface);
    border: 1px solid var(--studio-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.studio-pane-header {
    background: #f8fafc;
    padding: 12px 18px;
    border-bottom: 1px solid var(--studio-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.studio-pane-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--studio-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.studio-pane-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    position: relative;
}

.studio-pane-body::-webkit-scrollbar {
    width: 8px;
}
.studio-pane-body::-webkit-scrollbar-track {
    background: #f8fafc;
}
.studio-pane-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.studio-pane-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* --- CODE EDITOR & HIGHLIGHT LAYER --- */
.studio-editor-wrapper {
    position: relative;
    flex-grow: 1;
    background: #ffffff;
    height: 100%;
    container-type: inline-size;
    container-name: editorWrapper;
}

.studio-code-font {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.85;
    letter-spacing: -0.01em;
    padding: 18px 22px 30px 22px !important;
    box-sizing: border-box;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    border: none;
    position: relative !important;
    flex: 1 1 0% !important;
    min-height: 0 !important;
    width: 100% !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#codeEditor {
    background: white;
    color: #0f172a;
    caret-color: #2563eb;
    resize: none;
    outline: none;
    overflow-y: auto;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    flex: 1 1 0% !important;
    min-height: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 18px 22px 30px 22px !important;
    z-index: 2;
}

/* Image display standards: ensure natural aspect ratio preservation */
.quiz-image,
#codeEditor img,
.question-box img,
.studio-pane img,
.studio-editor-wrapper img {
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
}

#codeEditor::selection {
    background: rgba(37, 99, 235, 0.25);
    color: #000;
}

#codeEditor::-webkit-scrollbar {
    width: 12px;
}
#codeEditor::-webkit-scrollbar-track {
    background: #f8fafc;
}
#codeEditor::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border: 3px solid #f8fafc;
    border-radius: 8px;
}
#codeEditor::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* --- SYNTAX HIGHLIGHT COLORS --- */
.hl-question { color: #2563eb; }
.hl-option { color: #7c3aed; }
.hl-correct { color: #059669; }
.hl-image { color: #b91c1c; }
.hl-math { color: #0284c7; }
.hl-group { color: #b45309; }
.hl-html { color: #64748b; }

/* ========================================================
   MODERN EDITOR STATUS BAR
   ======================================================== */
.editor-status-bar {
    position: relative;
    flex-shrink: 0;
    width: 100%;
    height: 36px;
    min-height: 36px;
    max-height: 36px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 14px;
    font-size: 0.78rem;
    color: #475569;
    z-index: 10;
    box-sizing: border-box;
    user-select: none;
    overflow: hidden;
    flex-wrap: nowrap !important;
}

.status-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    min-width: 0;
    max-width: 65%;
    white-space: nowrap;
    overflow: hidden;
}

.status-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 1;
    min-width: 0;
    margin-left: auto;
    white-space: nowrap;
    overflow: hidden;
    justify-content: flex-end;
    flex-wrap: nowrap !important;
}

.status-divider {
    width: 1px;
    height: 14px;
    background: #cbd5e1;
    display: inline-block;
    flex-shrink: 0;
}

.status-text-count {
    color: #64748b;
    font-size: 0.75rem;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #475569;
    font-weight: 500;
    white-space: nowrap;
}

.status-pill-q {
    background: #eff6ff;
    color: #1d4ed8;
    padding: 2px 8px;
    border-radius: 5px;
    font-weight: 600;
    border: 1px solid #dbeafe;
    cursor: pointer;
    transition: background 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.status-pill-q:hover {
    background: #dbeafe;
}

.status-shortcut-hint {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #64748b;
    font-size: 0.72rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-shortcut-hint kbd {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 1px 5px;
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    color: #1e293b;
    box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}

/* Responsive theo chiều rộng thực tế của khung soạn thảo (Container Queries - cả anonymous lẫn named cho Safari WebKit) */
@container (max-width: 780px) {
    .hide-on-compact {
        display: none !important;
    }
}

@container editorWrapper (max-width: 780px) {
    .hide-on-compact {
        display: none !important;
    }
}

@container (max-width: 560px) {
    .status-shortcut-hint {
        display: none !important;
    }
}

@container editorWrapper (max-width: 560px) {
    .status-shortcut-hint {
        display: none !important;
    }
}

/* Fallback Media Queries cho máy tính xách tay (MacBook 13"/14" với độ phân giải 1280px - 1440px) */
@media (max-width: 1440px) {
    .hide-on-compact {
        display: none !important;
    }
}

@media (max-width: 1024px) {
    .status-shortcut-hint {
        display: none !important;
    }
}

/* ========================================================
   FLOATING SLASH COMMAND PALETTE (/ MENU)
   ======================================================== */
.editor-slash-menu {
    position: absolute;
    width: 320px;
    max-height: 340px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15), 0 0 1px 1px rgba(15, 23, 42, 0.08);
    border: 1px solid #e2e8f0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slashMenuPop 0.12s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slashMenuPop {
    from {
        opacity: 0;
        transform: translateY(4px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.slash-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.72rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.slash-menu-hint {
    font-weight: 500;
    color: #94a3b8;
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.7rem;
}

.slash-menu-list {
    overflow-y: auto;
    max-height: 290px;
    padding: 4px;
}

.slash-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s ease;
    user-select: none;
}

.slash-menu-item:hover,
.slash-menu-item.active {
    background: #f1f5f9;
}

.slash-menu-item.active {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 6px 9px;
}

.slash-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.slash-item-content {
    flex: 1;
    min-width: 0;
}

.slash-item-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.25;
}

.slash-item-desc {
    font-size: 0.74rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.slash-item-badge {
    background: #f1f5f9;
    color: #475569;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    font-family: inherit;
    flex-shrink: 0;
}

.slash-menu-item.active .slash-item-badge {
    background: #dbeafe;
    color: #1e40af;
    border-color: #bfdbfe;
}

.slash-menu-empty {
    padding: 20px 12px;
    text-align: center;
    color: #64748b;
    font-size: 0.82rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.slash-menu-empty i {
    font-size: 1.5rem;
    color: #94a3b8;
}

/* --- AI DASHBOARD TRONG STUDIO --- */
.studio-ai-panel {
    background: linear-gradient(135deg, #fdf4ff 0%, #f5f3ff 50%, #eff6ff 100%);
    border: 1.5px solid #d8b4fe;
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: 0 4px 15px rgba(147, 51, 234, 0.08);
    display: none;
    animation: fadeInDown 0.3s ease;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- PRACTICE & EXAM PREVIEW IN STUDIO --- */
.studio-test-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 0 60px 0;
}

/* --- MODAL DIALOGS --- */
.studio-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.studio-modal-box {
    background: #ffffff;
    border-radius: 16px;
    width: 90%;
    max-width: 540px;
    padding: 28px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: modalScaleUp 0.25s ease-out;
    border: 1px solid var(--studio-border);
}

@keyframes modalScaleUp {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* --- STUDIO TASK PROCESSING OVERLAY --- */
.studio-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.72) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    animation: fadeInDown 0.25s ease-out;
}

.studio-loading-card {
    background: #ffffff !important;
    border-radius: 24px !important;
    padding: 38px 32px 32px 32px !important;
    width: 90% !important;
    max-width: 460px !important;
    text-align: center !important;
    box-shadow: 0 25px 60px -12px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(226, 232, 240, 0.8) !important;
    animation: modalScaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    position: relative !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}

.studio-loading-card::before {
    content: '' !important;
    display: block !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 4px !important;
    background: linear-gradient(90deg, #00d2ff, #2d79f3, #2d4af3) !important;
}

.studio-spinner-ring {
    display: none;
}

.studio-progress-percent {
    font-size: 1.85rem !important;
    font-weight: 800 !important;
    color: #2563eb !important;
    text-shadow: none !important;
    margin: 0 0 8px 0 !important;
    letter-spacing: -0.5px !important;
    font-variant-numeric: tabular-nums !important;
}

.studio-progress-bar-bg {
    width: 100% !important;
    max-width: 380px !important;
    height: 8px !important;
    background: #f1f5f9 !important;
    border-radius: 999px !important;
    overflow: hidden !important;
    margin: 0 auto 18px auto !important;
    border: 1px solid #e2e8f0 !important;
}

.studio-progress-bar-fill {
    height: 100% !important;
    background: linear-gradient(90deg, #00d2ff 0%, #2d79f3 50%, #2d4af3 100%) !important;
    border-radius: 999px !important;
    transition: width 0.4s ease !important;
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.45) !important;
}

.studio-loading-title {
    color: #0f172a !important;
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    margin: 0 0 6px 0 !important;
    letter-spacing: normal !important;
    text-shadow: none !important;
}

.studio-loading-sub {
    color: #64748b !important;
    font-size: 0.88rem !important;
    margin: 0 !important;
    max-width: 380px !important;
    line-height: 1.5 !important;
}

/* --- RESPONSIVE WORKSPACE & NAVBAR --- */
@media (max-width: 1440px) {
    .studio-brand-text {
        display: none;
    }
    .studio-brand-badge {
        padding: 5px 8px;
    }
    .studio-title-box {
        max-width: 380px;
    }
}

@media (max-width: 1260px) {
    .studio-nav-left .nav-btn-text {
        display: none;
    }
    .studio-back-btn {
        padding: 6px 10px;
    }
    .studio-title-box {
        min-width: 120px;
        max-width: 320px;
    }
    .studio-navbar {
        padding: 8px 14px;
        gap: 8px;
    }
    .btn-studio-ai, .btn-studio-outline, .btn-studio-primary {
        padding: 6px 10px;
        font-size: 0.82rem;
    }
}

@media (max-width: 1080px) {
    .studio-navbar {
        flex-wrap: wrap;
        padding: 8px 14px;
        gap: 10px;
    }
    .studio-nav-left {
        width: 100%;
        order: 1;
        justify-content: flex-start;
    }
    .studio-nav-right {
        width: 100%;
        order: 2;
        justify-content: space-between;
        padding-top: 6px;
        border-top: 1px dashed #e2e8f0;
    }
    .studio-nav-left .nav-btn-text {
        display: inline !important;
    }
    .studio-brand-text {
        display: inline !important;
    }
    .studio-title-box {
        max-width: none;
        flex: 1 1 auto;
    }
}

@media (max-width: 992px) {
    .studio-split-layout {
        flex-direction: column;
        height: auto;
    }
    .studio-pane {
        width: 100%;
        height: 550px;
    }
}

/* ========================================================
   CẤU TRÚC ĐỀ THI MỚI BỘ GD&ĐT: ĐÚNG / SAI & TRẢ LỜI NGẮN
   ======================================================== */
.azota-tf-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.azota-tf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  background: var(--azota-bg, #f8fafc);
  border: 1.5px solid var(--azota-border, #e2e8f0);
  border-radius: 12px;
  transition: all 0.2s ease;
}
.azota-tf-row:hover {
  border-color: #cbd5e1;
  background: #ffffff;
}
.azota-tf-statement {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.98rem;
  color: var(--azota-text, #0f172a);
  line-height: 1.5;
  flex: 1;
}
.azota-tf-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #e2e8f0;
  color: #334155;
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
}
.azota-tf-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.azota-tf-btn {
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}
.azota-tf-btn:hover {
  border-color: #4f46e5;
  color: #4f46e5;
}
.azota-tf-btn.selected-true {
  background: #10b981 !important;
  border-color: #059669 !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}
.azota-tf-btn.selected-false {
  background: #f43f5e !important;
  border-color: #e11d48 !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.3);
}
.azota-tf-btn.correct-state {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #059669 !important;
}
.azota-tf-btn.wrong-state {
  background: #f43f5e !important;
  color: #ffffff !important;
  border-color: #e11d48 !important;
}

/* Dạng trả lời ngắn */
.azota-sa-box {
  margin-top: 14px;
  padding: 16px;
  background: var(--azota-bg, #f8fafc);
  border: 1.5px dashed var(--azota-border, #cbd5e1);
  border-radius: 12px;
}
.azota-sa-input {
  width: 100%;
  max-width: 320px;
  padding: 10px 14px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--azota-text, #0f172a);
  background: #ffffff;
  border: 2px solid var(--azota-border, #e2e8f0);
  border-radius: 8px;
  outline: none;
  transition: all 0.2s ease;
}
.azota-sa-input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.azota-sa-input.correct {
  border-color: #10b981 !important;
  background: #f0fdf4 !important;
  color: #15803d !important;
}
.azota-sa-input.incorrect {
  border-color: #f43f5e !important;
  background: #fff1f2 !important;
  color: #be123c !important;
}


/* ========================================================
   HOCNHANHTN STUDIO - MOBILE RESPONSIVE OPTIMIZATIONS
   ======================================================== */
.studio-mobile-view-tabs {
  display: none;
}

.studio-mobile-float-toggle {
  display: none;
}

@media (max-width: 860px) {
  /* --- CẤU TRÚC STUDIO TRÊN ĐIỆN THOẠI (APP STRUCTURE) --- */
  .studio-body {
    background-color: #f8fafc !important;
    padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .studio-workspace {
    padding: 8px !important;
    margin-top: 0 !important;
  }
  .studio-navbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 900 !important;
    padding: 8px 12px !important;
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03) !important;
    flex-direction: column !important;
    gap: 8px !important;
  }
  .studio-nav-left {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
  }
  .studio-brand-badge {
    display: none !important;
  }
  #btnOpenPublishMobile,
  .studio-mobile-publish-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px 14px !important;
    font-size: 0.82rem !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
    background: var(--studio-primary) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25) !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
  #btnOpenPublishMobile:hover,
  .studio-mobile-publish-btn:hover {
    background: var(--studio-primary-hover) !important;
  }
  .studio-desktop-publish-btn {
    display: none !important;
  }
  #pillModePractice,
  #pillModeExam {
    display: none !important;
  }
  .studio-back-btn .nav-btn-text {
    display: none !important;
  }
  .studio-brand-logo {
    width: 22px !important;
    height: 22px !important;
    border-radius: 6px !important;
  }
  .studio-brand-text {
    display: none !important;
  }
  .studio-back-btn {
    padding: 6px 10px !important;
    font-size: 0.8rem !important;
    border-radius: 10px !important;
    background: #f1f5f9 !important;
    border: none !important;
    color: #475569 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
  }
  #btnDiscardOrDelete {
    background: #fef2f2 !important;
    color: #ef4444 !important;
    border: none !important;
    padding: 6px 10px !important;
  }
  #btnDiscardOrDelete span {
    display: none !important;
  }
  #btnDiscardOrDelete i {
    margin: 0 !important;
    font-size: 1.1rem !important;
  }
  .studio-nav-right {
    width: 100% !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding-bottom: 2px !important;
    gap: 6px !important;
    justify-content: flex-start !important;
  }
  .studio-nav-right::-webkit-scrollbar {
    display: none !important;
  }
  .studio-mode-pill-group {
    background: #f1f5f9 !important;
    padding: 3px !important;
    border-radius: 12px !important;
    flex-shrink: 0 !important;
    display: inline-flex !important;
  }
  .studio-mode-pill {
    padding: 5px 10px !important;
    font-size: 0.78rem !important;
    border-radius: 9px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
  }
  .btn-studio-ai, .btn-studio-outline {
    padding: 6px 12px !important;
    font-size: 0.8rem !important;
    white-space: nowrap !important;
    border-radius: 10px !important;
    flex-shrink: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
  }

  #btnOpenPublish,
  .studio-desktop-publish-btn,
  .studio-nav-right #btnOpenPublish,
  .studio-nav-right .studio-desktop-publish-btn {
    display: none !important;
  }

  /* --- BOTTOM DOCK CHUYỂN TAB MOBILE (NATIVE APP FEEL) --- */
  .studio-mobile-view-tabs {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    transform: none !important;
    z-index: 998 !important;
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px)) 16px !important;
    border-top: 1px solid rgba(226, 232, 240, 0.9) !important;
    border-radius: 0 !important;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.05) !important;
    justify-content: center !important;
    gap: 12px !important;
    box-sizing: border-box !important;
  }
  .studio-m-tab-btn {
    flex: 1 !important;
    max-width: 220px !important;
    padding: 9px 16px !important;
    border-radius: 12px !important;
    font-size: 0.88rem !important;
    font-weight: 700 !important;
    color: #64748b !important;
    background: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    transition: all 0.2s ease !important;
  }
  .studio-m-tab-btn.active {
    background: var(--studio-primary) !important;
    color: #ffffff !important;
    border-color: var(--studio-primary) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25) !important;
  }
  .studio-mobile-float-toggle {
    display: none !important;
  }

  /* --- CÁC KHUNG SOẠN THẢO & XEM TRƯỚC TRÊN MOBILE --- */
  .studio-split-layout {
    display: block !important;
    height: auto !important;
    background: transparent !important;
  }
  .studio-split-layout.mobile-tab-preview #previewPane {
    display: flex !important;
    width: 100% !important;
    height: calc(100dvh - 185px - env(safe-area-inset-bottom, 0px)) !important;
    min-height: 420px !important;
    margin: 0 0 65px 0 !important;
    border-radius: 14px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04) !important;
    border: 1px solid #e2e8f0 !important;
    overflow: hidden !important;
  }
  .studio-split-layout.mobile-tab-preview #editorPane {
    display: none !important;
  }
  .studio-split-layout.mobile-tab-code #previewPane {
    display: none !important;
  }
  .studio-split-layout.mobile-tab-code #editorPane {
    display: flex !important;
    width: 100% !important;
    height: calc(100dvh - 185px - env(safe-area-inset-bottom, 0px)) !important;
    min-height: 420px !important;
    margin: 0 0 65px 0 !important;
    border-radius: 14px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04) !important;
    border: 1px solid #e2e8f0 !important;
    overflow: hidden !important;
  }

  /* --- HEADER CỦA TỪNG KHUNG --- */
  .studio-pane-header {
    padding: 8px 12px !important;
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    gap: 8px !important;
    min-height: 42px !important;
    box-sizing: border-box !important;
  }
  .studio-pane-title {
    font-size: 0.88rem !important;
    font-weight: 700 !important;
  }
  #studioQCountBadge {
    display: inline-flex !important;
    padding: 3px 8px !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
  }
  #autosaveIndicator {
    display: inline-flex !important;
    font-size: 0.75rem !important;
    color: #059669 !important;
  }

  /* --- TOOLBAR SOẠN THẢO TRÊN MOBILE (VUỐT NGANG 1 DÒNG DUY NHẤT) --- */
  .studio-word-toolbar {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding: 5px 8px !important;
    gap: 3px !important;
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
  }
  .studio-word-toolbar::-webkit-scrollbar {
    display: none !important;
  }
  .toolbar-group {
    flex-shrink: 0 !important;
    gap: 2px !important;
  }
  .toolbar-btn {
    flex-shrink: 0 !important;
    height: 32px !important;
    min-width: 32px !important;
    padding: 0 5px !important;
    font-size: 0.95rem !important;
  }
  .toolbar-divider {
    flex-shrink: 0 !important;
    margin: 0 3px !important;
    height: 18px !important;
  }

  /* Dropdown bảng màu cố định gọn gàng trên mobile */
  .toolbar-color-palette {
    position: fixed !important;
    top: auto !important;
    bottom: 75px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: min(280px, calc(100vw - 32px)) !important;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.2) !important;
    z-index: 1000 !important;
  }

  /* --- NỘI DUNG VÙNG SOẠN CODE --- */
  .studio-code-font {
    font-size: 14.5px !important;
    line-height: 1.65 !important;
    padding: 12px 14px 100px 14px !important;
  }

  /* --- THANH TRẠNG THÁI (STATUS BAR) TRÊN MOBILE --- */
  .editor-status-bar {
    height: 36px !important;
    padding: 0 10px !important;
    font-size: 0.78rem !important;
    gap: 8px !important;
    background: #f8fafc !important;
    border-top: 1px solid #e2e8f0 !important;
  }
  .status-bar-left {
    gap: 8px !important;
    flex: 1 !important;
    min-width: 0 !important;
    justify-content: space-between !important;
  }
  .status-pill-q {
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 0.78rem !important;
    padding: 3px 10px !important;
    border-radius: 8px !important;
  }
  .status-bar-right {
    display: none !important; /* Ẩn phím tắt bàn phím vật lý trên điện thoại */
  }
  .status-divider {
    display: none !important;
  }
  .status-text-count {
    display: none !important;
  }

  /* --- KHUNG XEM TRƯỚC (PREVIEW) --- */
  .studio-pane-body {
    padding: 12px 10px 100px 10px !important;
    background: #f8fafc !important;
  }
  .question-box {
    padding: 16px 14px !important;
    border-radius: 14px !important;
    margin-bottom: 14px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02) !important;
    border: 1px solid #e2e8f0 !important;
  }
  .question-title {
    font-size: 0.98rem !important;
    line-height: 1.55 !important;
  }
  .azota-tf-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
    padding: 12px 14px !important;
    border-radius: 12px !important;
  }
  .azota-tf-actions {
    width: 100% !important;
    justify-content: flex-end !important;
  }
  .azota-tf-btn {
    flex: 1 !important;
    padding: 8px !important;
    justify-content: center !important;
  }

  /* --- MENU GÕ / LỆNH NHANH (SLASH MENU) TRÊN MOBILE --- */
  .editor-slash-menu {
    max-width: calc(100vw - 28px) !important;
    width: 290px !important;
    max-height: 260px !important;
    border-radius: 12px !important;
  }
  .slash-menu-item {
    padding: 8px 10px !important;
  }
  .slash-item-desc {
    font-size: 0.72rem !important;
  }

  /* --- BẢNG ĐIỀU KHIỂN AI TRÊN MOBILE --- */
  .studio-ai-panel {
    padding: 16px 14px !important;
    border-radius: 16px !important;
    margin-bottom: 14px !important;
  }
  .ai-dashboard-title {
    font-size: 1.05rem !important;
  }
  .ai-dashboard-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .ai-dashboard-header > div:last-child {
    display: flex !important;
    justify-content: space-between !important;
    width: 100% !important;
  }
  #aiCustomPrompt {
    width: 100% !important;
    min-width: 0 !important;
    border-radius: 10px !important;
    padding: 10px 12px !important;
    font-size: 0.86rem !important;
  }
  #btnAICheck, #btnCrossCheckAI {
    width: 100% !important;
    border-radius: 10px !important;
    padding: 10px 14px !important;
    justify-content: center !important;
    font-size: 0.88rem !important;
  }
  .ai-quick-prompts {
    gap: 6px !important;
  }
  .ai-quick-chip {
    padding: 5px 10px !important;
    font-size: 0.78rem !important;
  }

  /* --- CHẾ ĐỘ THI THỬ & LÀM THỬ TRÊN MOBILE --- */
  .studio-test-container {
    padding: 8px 8px 100px 8px !important;
  }
  .studio-test-header-card {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 14px !important;
  }
  .studio-test-header-card button {
    width: 100% !important;
    justify-content: center !important;
  }
  #testExamSubmitArea button {
    width: 100% !important;
    padding: 12px 20px !important;
    font-size: 1rem !important;
  }

  /* --- TẤT CẢ CÁC MODAL HỘP THOẠI TRÊN MOBILE --- */
  .studio-modal-box {
    width: 95% !important;
    max-width: 95% !important;
    padding: 18px 14px !important;
    border-radius: 16px !important;
    max-height: 88vh !important;
  }
  .studio-modal-box h2 {
    font-size: 1.15rem !important;
  }
  .studio-modal-box input, .studio-modal-box select {
    padding: 10px 12px !important;
    font-size: 0.9rem !important;
    border-radius: 10px !important;
  }
  .docx-options-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  .pub-stat-cards-group {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .pub-stat-cards-group > div:first-child {
    grid-column: span 2 !important;
  }
  .quiz-table-wrapper,
  .question-box table,
  #codeEditor table {
    max-width: 100% !important;
    overflow-x: auto !important;
    display: block !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

@media (max-width: 420px) {
  .btn-header-label {
    display: none !important;
  }
  .studio-back-btn .nav-btn-text {
    display: none !important;
  }
}


/* --- AI FEEDBACK EXPANDED CATEGORIES & QUICK PROMPTS --- */
.ai-cat-explain {
    background: #f0fdf4 !important;
    border-color: #86efac !important;
    color: #15803d !important;
    font-weight: 700 !important;
}

.ai-cat-latex {
    background: #fff7ed !important;
    border-color: #fdba74 !important;
    color: #c2410c !important;
    font-weight: 700 !important;
}

.btn-ai-explain {
    background: #10b981 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
    transition: all 0.15s ease;
}

.btn-ai-explain:hover {
    background: #059669 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.35);
}

.ai-quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 6px;
}

.ai-quick-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #ffffff;
    border: 1px solid #d8b4fe;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #6b21a8;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
}

.ai-quick-chip:hover {
    background: #f5f3ff;
    border-color: #9333ea;
    color: #581c87;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(147, 51, 234, 0.15);
}

.ai-quick-chip i {
    font-size: 1rem;
}


/* Ẩn hoàn toàn nút nộp bài cũ ở đáy danh sách câu hỏi vì đã có nút cố định trên Header & Bảng câu hỏi */
#submitBtn {
    display: none !important;
}

/* Đảm bảo thanh điều hướng mobile KHÔNG BAO GIỜ hiển thị trên Desktop (> 960px) */
@media (min-width: 961px) {
    #azotaMobileExamBar,
    .azota-mobile-exam-bar {
        display: none !important;
    }
}

/* ==========================================================================
   Quiz Data Table Styling (Tables in question stems)
   ========================================================================== */
.quiz-table {
    border-collapse: collapse;
    margin: 12px 0;
    width: auto;
    max-width: 100%;
    font-size: 0.95rem;
    line-height: 1.5;
    border: 1px solid #cbd5e1;
    background-color: #ffffff;
    border-radius: 6px;
    overflow: hidden;
}

.dark .quiz-table {
    border-color: #334155;
    background-color: #1e293b;
    color: #e2e8f0;
}

.quiz-table th,
.quiz-table td {
    border: 1px solid #cbd5e1;
    padding: 8px 12px;
    text-align: left;
    vertical-align: middle;
}

.dark .quiz-table th,
.dark .quiz-table td {
    border-color: #334155;
}

.quiz-table th {
    background-color: #f1f5f9;
    font-weight: 600;
    color: #1e293b;
}

.dark .quiz-table th {
    background-color: #334155;
    color: #f8fafc;
}

.quiz-table tr:nth-child(even) td {
    background-color: #f8fafc;
}

.dark .quiz-table tr:nth-child(even) td {
    background-color: #1e293b;
}


/* Enhanced Quiz Table & Markdown Table Styling */
.quiz-table-wrapper {
    overflow-x: auto;
    margin: 14px 0;
    display: block;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.quiz-content-table {
    border-collapse: collapse;
    margin: 0 auto;
    width: auto;
    max-width: 100%;
    font-size: 0.95rem;
    line-height: 1.5;
    border: 1.5px solid #cbd5e1;
    background-color: #ffffff;
    border-radius: 6px;
    overflow: hidden;
    text-align: center;
}

.dark .quiz-content-table {
    border-color: #334155;
    background-color: #1e293b;
    color: #e2e8f0;
}

.quiz-content-table th,
.quiz-content-table td {
    border: 1px solid #cbd5e1;
    padding: 8px 14px;
    text-align: center;
    vertical-align: middle;
}

.dark .quiz-content-table th,
.dark .quiz-content-table td {
    border-color: #334155;
}

.quiz-content-table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #1e293b;
}

.dark .quiz-content-table th {
    background-color: #334155;
    color: #f8fafc;
}

.quiz-content-table tr:nth-child(even) td {
    background-color: #fcfdfe;
}

.dark .quiz-content-table tr:nth-child(even) td {
    background-color: #1e293b;
}


/* ==========================================================================
   STUDIO WORD-STYLE RIBBON TOOLBAR & RICH TEXT FORMATTING
   ========================================================================== */
.studio-word-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 10px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    user-select: none;
    position: relative;
    z-index: 20;
    flex-shrink: 0 !important;
}

.toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    min-width: 30px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #334155;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    box-sizing: border-box;
    outline: none;
    line-height: 1;
}

.toolbar-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #cbd5e1;
}

.toolbar-btn:active, .toolbar-btn.is-active {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #93c5fd;
}

.toolbar-btn-color {
    flex-direction: column;
    padding: 2px 6px;
    height: 30px;
    gap: 1px;
}

.toolbar-btn-color .color-indicator {
    width: 14px;
    height: 3px;
    border-radius: 1px;
    display: block;
}

.toolbar-btn-color .arrow-down,
.toolbar-btn-highlighted .arrow-down {
    font-size: 0.75rem;
    color: #64748b;
    margin-left: 2px;
}

.toolbar-btn-highlighted {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
    font-weight: 600;
}

.toolbar-btn-highlighted:hover {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}

.toolbar-btn-subtle {
    background: #ffffff;
    border-color: #e2e8f0;
    font-size: 0.8rem;
    gap: 4px;
    padding: 0 8px;
}

.toolbar-btn-subtle:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.toolbar-btn-latex {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #ea580c;
    font-weight: 600;
    gap: 4px;
    padding: 0 8px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(234, 88, 12, 0.08);
}

.toolbar-btn-latex:hover {
    background: #ffedd5;
    border-color: #fdba74;
    color: #c2410c;
    transform: translateY(-1px);
}

.toolbar-btn-latex:active {
    background: #fed7aa;
    transform: translateY(0);
}

.btn-text-sm {
    font-size: 0.8rem;
    font-weight: 600;
}

.toolbar-divider {
    display: inline-block;
    width: 1px;
    height: 20px;
    background: #cbd5e1;
    margin: 0 4px;
    align-self: center;
}

/* Dropdown Wrapper & Palettes */
.toolbar-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.toolbar-color-palette {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.2), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
    padding: 10px 12px;
    z-index: 1000;
    width: 180px;
    animation: toolbarFadeIn 0.15s ease-out;
}

@keyframes toolbarFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.palette-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.04em;
}

.palette-colors {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.palette-color-box {
    width: 32px;
    height: 28px;
    border-radius: 5px;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.15);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.palette-color-box:hover {
    transform: scale(1.12);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
    z-index: 2;
}

.palette-color-clear {
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    font-size: 1rem;
}

.palette-custom {
    border-top: 1px solid #f1f5f9;
    padding-top: 6px;
    font-size: 0.78rem;
    color: #475569;
}

.palette-custom label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.palette-custom input[type="color"] {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Dropdown Menu for Image Insert */
.toolbar-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
    padding: 6px;
    z-index: 1000;
    width: 250px;
    animation: toolbarFadeIn 0.15s ease-out;
}

.toolbar-dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #1e293b;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.toolbar-dropdown-menu .dropdown-item:hover {
    background: #f1f5f9;
    color: #2563eb;
}

.toolbar-dropdown-menu .dropdown-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 4px 0;
}

.toolbar-dropdown-menu .dropdown-hint {
    padding: 6px 10px;
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.4;
    background: #f8fafc;
    border-radius: 4px;
}

/* ==========================================================================
   IN-EDITOR IMAGE SELECTION, RESIZE HANDLES & FLOATING BAR
   ========================================================================== */
#codeEditor img {
    cursor: grab;
    -webkit-user-drag: element;
    user-select: none;
    transition: outline 0.15s ease, opacity 0.2s ease;
}

#codeEditor img:active {
    cursor: grabbing;
}

#codeEditor img:hover {
    outline: 2px dashed #93c5fd;
    outline-offset: 2px;
}

#codeEditor img.editor-img-active {
    outline: 2.5px solid #2563eb !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15) !important;
}

#codeEditor img.editor-img-dragging {
    opacity: 0.35 !important;
    outline: 2.5px dashed #2563eb !important;
    outline-offset: 3px !important;
}

#preview-content img {
    cursor: grab;
    -webkit-user-drag: element;
}

/* Caret nhấp nháy chỉ báo vị trí thả ảnh chuẩn xác (Drop Caret Indicator) */
.editor-drop-caret {
    position: absolute;
    width: 2.5px;
    background-color: #2563eb;
    border-radius: 1px;
    pointer-events: none;
    z-index: 60;
    box-shadow: 0 0 5px rgba(37, 99, 235, 0.85);
    animation: editorDropCaretBlink 0.75s steps(1) infinite;
    display: none;
    transition: top 0.05s ease, left 0.05s ease;
}

.editor-drop-caret::before,
.editor-drop-caret::after {
    content: '';
    position: absolute;
    left: -3px;
    width: 8.5px;
    height: 2.5px;
    background-color: #2563eb;
    border-radius: 1px;
}

.editor-drop-caret::before {
    top: -1px;
}

.editor-drop-caret::after {
    bottom: -1px;
}

@keyframes editorDropCaretBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ==========================================================================
   CÔNG THỨC TOÁN HỌC TRONG KHUNG SOẠN THẢO CODE (#codeEditor)
   ========================================================================== */
.editor-formula {
    color: #c026d3 !important;
    font-weight: 600 !important;
    background: rgba(192, 38, 211, 0.08) !important;
    border: 1px solid rgba(192, 38, 211, 0.22) !important;
    border-radius: 4px !important;
    padding: 1px 5px !important;
    margin: 0 1px !important;
    display: inline-block !important;
    cursor: grab !important;
    -webkit-user-drag: element !important;
    transition: all 0.15s ease !important;
    font-family: 'Cambria Math', 'KaTeX_Math', 'Consolas', 'Fira Code', monospace !important;
    font-size: 0.96em !important;
    line-height: 1.3 !important;
    vertical-align: baseline !important;
    user-select: none !important;
}

.editor-formula:active {
    cursor: grabbing !important;
}

.editor-formula:hover {
    background: rgba(192, 38, 211, 0.16) !important;
    border-color: #c026d3 !important;
    box-shadow: 0 1px 4px rgba(192, 38, 211, 0.2) !important;
    transform: translateY(-0.5px) !important;
}

.editor-formula.editor-formula-dragging {
    opacity: 0.35 !important;
    outline: 2px dashed #c026d3 !important;
    outline-offset: 2px !important;
}

.editor-formula.editor-formula-selected {
    background: rgba(192, 38, 211, 0.22) !important;
    border-color: #c026d3 !important;
    box-shadow: 0 0 0 2px rgba(192, 38, 211, 0.35) !important;
}

.editor-formula-action-pill {
    position: absolute;
    z-index: 100;
    display: none;
    align-items: center;
    gap: 4px;
    background: #1e293b;
    border-radius: 20px;
    padding: 3px 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
    pointer-events: auto;
    user-select: none;
    animation: formulaPillFadeIn 0.15s ease-out;
}

@keyframes formulaPillFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.formula-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: #f8fafc;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.12s ease;
    white-space: nowrap;
}

.formula-pill-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.formula-pill-btn-edit {
    color: #38bdf8;
}

.formula-pill-btn-edit:hover {
    background: rgba(56, 189, 248, 0.18);
    color: #7dd3fc;
}

.formula-pill-btn-delete {
    color: #f87171;
}

.formula-pill-btn-delete:hover {
    background: rgba(248, 113, 113, 0.18);
    color: #fca5a5;
}

.editor-img-resizer-overlay {
    position: absolute;
    border: 2px solid #2563eb;
    pointer-events: none;
    z-index: 50;
    box-sizing: border-box;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.img-resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border: 2px solid #2563eb;
    border-radius: 2px;
    pointer-events: auto;
    z-index: 52;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
    transition: transform 0.1s ease, background 0.1s ease;
}

.img-resize-handle:hover {
    background: #2563eb;
    transform: scale(1.25);
}

.img-resize-handle.handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.img-resize-handle.handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.img-resize-handle.handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.img-resize-handle.handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }

.img-dim-tooltip {
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.88);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    letter-spacing: 0.02em;
}

/* Floating quick toolbar above image */
.img-float-toolbar {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: #ffffff;
    border-radius: 8px;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 12px 24px -4px rgba(15, 23, 42, 0.35);
    pointer-events: auto;
    z-index: 55;
    white-space: nowrap;
    animation: toolbarFadeIn 0.15s ease-out;
}

.img-float-group {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.img-tool-btn {
    background: transparent;
    border: none;
    color: #cbd5e1;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 7px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.img-tool-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

.img-tool-divider {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 2px;
}

.img-tool-crop {
    background: #2563eb;
    color: #ffffff !important;
}

.img-tool-crop:hover {
    background: #1d4ed8 !important;
}

.img-tool-delete {
    color: #f87171 !important;
}

.img-tool-delete:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #ef4444 !important;
}

/* ==========================================================================
   IMAGE CROPPER MODAL (CANVAS-BASED)
   ========================================================================== */
.cropper-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.cropper-modal-container {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 860px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.4);
    animation: modalScaleUp 0.2s ease-out;
}

@keyframes modalScaleUp {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.cropper-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.cropper-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
}

.cropper-btn-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 6px;
    line-height: 1;
}

.cropper-btn-close:hover {
    color: #0f172a;
    background: #e2e8f0;
}

.cropper-modal-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    background: #0f172a;
}

.cropper-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    position: relative;
    min-height: 360px;
    user-select: none;
}

.cropper-image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 52vh;
}

#cropperSourceImg {
    display: block;
    max-width: 100%;
    max-height: 52vh;
    object-fit: contain;
    pointer-events: none;
    transition: transform 0.2s ease;
}

/* Crop Box Overlay */
.cropper-box {
    position: absolute;
    border: 2px solid #38bdf8;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.65);
    cursor: move;
    box-sizing: border-box;
}

.cropper-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.cropper-grid::before {
    content: '';
    position: absolute;
    top: 33.33%;
    bottom: 33.33%;
    left: 0;
    right: 0;
    border-top: 1px dashed rgba(255, 255, 255, 0.45);
    border-bottom: 1px dashed rgba(255, 255, 255, 0.45);
}

.cropper-grid::after {
    content: '';
    position: absolute;
    left: 33.33%;
    right: 33.33%;
    top: 0;
    bottom: 0;
    border-left: 1px dashed rgba(255, 255, 255, 0.45);
    border-right: 1px dashed rgba(255, 255, 255, 0.45);
}

/* 8 Crop Handles */
.crop-h {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #38bdf8;
    border: 1.5px solid #ffffff;
    box-sizing: border-box;
}

.crop-h-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.crop-h-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.crop-h-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.crop-h-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }

.crop-h-n { top: -5px; left: calc(50% - 5px); cursor: ns-resize; width: 14px; }
.crop-h-s { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; width: 14px; }
.crop-h-w { left: -5px; top: calc(50% - 5px); cursor: ew-resize; height: 14px; }
.crop-h-e { right: -5px; top: calc(50% - 5px); cursor: ew-resize; height: 14px; }

/* Cropper Controls below stage */
.cropper-controls {
    background: #1e293b;
    border-top: 1px solid #334155;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.cropper-control-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cropper-ctrl-label {
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cropper-ctrl-btn {
    background: #334155;
    border: 1px solid #475569;
    color: #e2e8f0;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cropper-ctrl-btn:hover {
    background: #475569;
    color: #ffffff;
}

.cropper-ctrl-btn.active {
    background: #2563eb;
    border-color: #3b82f6;
    color: #ffffff;
}

.cropper-control-divider {
    width: 1px;
    height: 20px;
    background: #475569;
    margin: 0 4px;
}

/* Cropper Modal Footer */
.cropper-modal-footer {
    padding: 12px 20px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cropper-info-text {
    font-size: 0.82rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 5px;
}

.cropper-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cropper-btn-cancel {
    padding: 8px 16px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #475569;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.cropper-btn-cancel:hover {
    background: #f1f5f9;
}

.cropper-btn-apply {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
    transition: all 0.15s ease;
}

.cropper-btn-apply:hover {
    background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 100%);
    transform: translateY(-1px);
}


/* ==========================================================================
   LATEX MATH MODAL & QUICK CHIPS
   ========================================================================== */
.latex-chip-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.9rem;
    font-family: inherit;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.latex-chip-btn:hover {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
    transform: translateY(-1px);
}

.latex-chip-btn:active {
    transform: translateY(0);
}

#latexFormulaInput:focus {
    outline: none;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
}

#latexLivePreview mjx-container {
    margin: 4px 0 !important;
}

/* ==========================================================================
   MATHTYPE WYSIWYG FORMULA EDITOR (CortexJS & MathLive the he moi)
   ========================================================================== */
:root, body {
    --keyboard-zindex: 2147483647 !important;
}

.ML__keyboard,
div.ML__keyboard,
.ML__keyboard-sink {
    z-index: 2147483647 !important;
    position: fixed !important;
    pointer-events: none !important;
}

.ML__keyboard.is-visible > .MLK__backdrop,
.ML__keyboard .MLK__backdrop,
.ML__keyboard .MLK__plate,
.ML__keyboard .MLK__rows,
.ML__keyboard .MLK__row,
.ML__keyboard .MLK__keycap,
.ML__keyboard [role="button"],
.ML__keyboard button {
    pointer-events: all !important;
}

#latexMathModal.studio-modal-overlay,
#latexMathModal.mathtype-modal-overlay,
#latexMathModal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(15, 23, 42, 0.55) !important;
    backdrop-filter: blur(4px) !important;
    display: none;
    align-items: flex-start !important;
    justify-content: center !important;
    z-index: 10000 !important;
    padding: 24px 16px 360px 16px !important;
    overflow-y: auto !important;
    animation: fadeInModal 0.18s ease-out;
}

@keyframes fadeInModal {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.mathtype-modal-container {
    background: #ffffff;
    width: 720px;
    max-width: 96vw;
    border-radius: 14px;
    box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0 auto;
}

.mathtype-modal-header {
    padding: 14px 20px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mathtype-title-main {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
}

.mathtype-btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.mathtype-btn-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.mathtype-wysiwyg-area {
    padding: 18px 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mathtype-mathfield-wrapper {
    background: #ffffff;
    border: 2px solid #059669;
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.08);
    transition: all 0.2s ease;
}

.mathtype-mathfield-wrapper.has-error {
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.12);
}

.mathtype-math-field {
    width: 100%;
    min-height: 52px;
    font-size: 1.35rem;
    outline: none;
    border: none;
    background: transparent;
    display: block;
    --primary: #059669;
    --keyboard-zindex: 2147483647;
}

.mathtype-math-field:focus-within {
    outline: none;
}

.mathtype-shortcut-hints {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #64748b;
}

.mathtype-shortcut-pill {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    padding: 3px 8px;
    border-radius: 5px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mathtype-shortcut-pill:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #cbd5e1;
}

.mathtype-assistant-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 6px;
    border-top: 1px dashed #cbd5e1;
}

.mathtype-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
}

.mathtype-assistant-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.mathtype-assistant-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.mathtype-assistant-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

.mathtype-assistant-btn.primary {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #059669;
}

.mathtype-assistant-btn.primary:hover {
    background: #d1fae5;
    color: #047857;
}

.mathtype-assistant-btn.danger {
    color: #dc2626;
    border-color: #fecaca;
    background: #fff5f5;
}

.mathtype-assistant-btn.danger:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.mathtype-eval-card {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.9rem;
    color: #166534;
}

.mathtype-eval-content {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.mathtype-eval-label {
    font-weight: 600;
    color: #166534;
    font-size: 0.88rem;
}

.mathtype-eval-math {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    font-size: 1.25rem;
    color: #047857 !important;
    display: inline-block;
    padding: 0 4px;
    box-shadow: none !important;
    pointer-events: auto;
    --primary: #047857;
}

.mathtype-eval-math:focus-within {
    outline: none !important;
    box-shadow: none !important;
}

.mathtype-eval-note {
    font-size: 0.82rem;
    color: #059669;
    font-style: italic;
    font-weight: 500;
}

.mathtype-eval-val {
    font-weight: 700;
    font-family: 'Cambria Math', serif;
    font-size: 1.05rem;
    color: #047857;
}

.mathtype-modal-footer {
    padding: 12px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.mathtype-display-mode {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.85rem;
    color: #334155;
}

.mathtype-mode-label {
    font-weight: 600;
}

.mathtype-radio-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.mathtype-radio-label code {
    background: #e2e8f0;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.78rem;
    color: #0f172a;
}

.mathtype-footer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mathtype-btn-toggle-kb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #059669;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mathtype-btn-toggle-kb:hover {
    background: #d1fae5;
    color: #047857;
}

.mathtype-btn-insert {
    background: #1d4ed8;
    color: #ffffff;
    border: none;
    padding: 8px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(29, 78, 216, 0.3);
    transition: all 0.12s ease;
}

.mathtype-btn-insert:hover {
    background: #1e40af;
    transform: translateY(-1px);
    box-shadow: 0 6px 12px -2px rgba(29, 78, 216, 0.4);
}


