/* IELTS Writing Widget - Standardized CSS (Architecture V2) */

/* --- 1. SHARED: FORM CONTROLS (Timer & Start) --- */
.ielts-timer-select {
    padding: 10px 15px;
    font-size: 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background-color: #fff;
    color: #374151;
    margin-right: 15px;
    cursor: pointer;
    /* Scoped — no transition:all */
    transition: border-color 120ms ease, box-shadow 120ms ease;
    font-family: 'Inter', sans-serif;
    height: 46px; /* Matches Reading Button Height */
    box-sizing: border-box;
}
.ielts-timer-select:hover { border-color: #007bff; }
.ielts-timer-select:focus { outline: none; border-color: #007bff; box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1); }

.ielts-header-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.ielts-header-candidate {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ielts-header-candidate-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: currentColor;
    line-height: 1;
}

.ielts-header-candidate-icon svg {
    display: block;
}

.ielts-header-candidate-text {
    font-weight: 700;
}

/* --- 2. BASE CONTAINER STYLES --- */
.ielts-final-wrapper {
  --footer-height: 80px; 
  --panel-padding: 25px;
  --mobile-footer-height: 50px; 
  --mobile-panel-padding: 10px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-user-select: none;
  user-select: none;
  padding: 10px;
  background-color: transparent;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* --- 3. HEADER SECTION --- */
.ielts-widget-header { 
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; gap: 20px; margin-bottom: 25px; flex-shrink: 0; width: 100%;
}
.ielts-widget-title { 
    font-size: 28px; font-weight: 700; color: #1a202c; margin: 0; padding: 0 15px; width: 100%; line-height: 1.3; 
}

.ielts-start-button { 
    background: linear-gradient(180deg,#27c184 0%,#1eb06f 100%); color: #fff; border: none; padding: 0 25px; height: 46px; 
    min-height: var(--ielts-lms-touch-target, 44px);
    font-size: 16px; font-weight: 600; border-radius: 8px; cursor: pointer; 
    transition: transform 180ms ease, box-shadow 180ms ease; display: inline-flex; 
    align-items: center; justify-content: center; text-decoration: none; box-shadow: 0 10px 24px rgba(30,176,111,.22);
}
.ielts-start-button:hover { background: linear-gradient(180deg,#27c184 0%,#1eb06f 100%); box-shadow: 0 12px 26px rgba(30,176,111,.26); transform: translateY(-1px); }
.ielts-start-button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(30,176,111,0.40); transform: translateY(-1px); }
.ielts-start-button:active { transform: scale(0.97); box-shadow: 0 4px 12px rgba(30,176,111,.18); }
.ielts-start-button:disabled { background: #94a3b8; cursor: not-allowed; transform: none; box-shadow: none; }

/* Attempt Badge (Shared) - FIXED Styles */
.ielts-attempt-badge { 
    height: 46px; 
    display: inline-flex !important; 
    vertical-align: middle;
    margin-left: 10px; /* Default spacing for desktop */
    align-items: center; 
    justify-content: center; 
    font-size: 13px; 
    color: #555; 
    background: #f0f2f5; 
    padding: 4px 14px; 
    border-radius: 15px; 
    border: 1px solid #e1e4e8; 
    font-weight: 600; 
    box-sizing: border-box; 
}

/* --- 4. INSTRUCTION ACCORDION STYLES --- */
.ielts-instruction-wrapper {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    display: block;
}

#ielts-instruction-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    padding: 8px 24px;
    min-height: var(--ielts-lms-touch-target, 44px);
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #475569;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    /* Scoped — no transition:all */
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
    margin-bottom: 10px;
    gap: 8px;
}

#ielts-instruction-toggle:hover {
    background-color: #f8fafc;
    border-color: #94a3b8;
    color: #1e293b;
}
#ielts-instruction-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.25);
}
#ielts-instruction-toggle:active {
    background-color: #f1f5f9;
}

.ielts-instruction-box {
    text-align: left;
    margin-top: 15px;
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-family: 'Inter', sans-serif;
    display: none;
}

.ielts-instruction-box h3 {
    margin-top: 0;
    font-size: 18px;
    color: #1e293b;
    font-weight: 600;
}

.ielts-instruction-box ul {
    padding-left: 20px;
    color: #475569;
    line-height: 1.6;
    list-style-type: disc;
}

.ielts-instruction-box ul li {
    margin-bottom: 8px;
}

.ielts-instruction-box strong {
    font-weight: 600;
    color: #1e293b;
}

.ielts-warning-text {
    color: #dc3545 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    margin-top: 12px !important;
    display: block !important;
}

/* Render editor-created tables with visible borders without requiring inline border attributes. */
.ielts-task-prompt table,
.ielts-review-prompt-box table,
.ielts-review-content table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    margin: 12px 0;
}

.ielts-task-prompt table th,
.ielts-task-prompt table td,
.ielts-review-prompt-box table th,
.ielts-review-prompt-box table td,
.ielts-review-content table th,
.ielts-review-content table td {
    border: 1px solid #ccc;
    padding: 6px;
    vertical-align: top;
}

/* --- 5. LOADING & STATES --- */
.ielts-loading-container { display: none; flex-direction: column; align-items: center; justify-content: center; min-height: 400px; text-align: center; color: #4a5568; font-size: 18px; font-weight: 500; }

.spinner, .ielts-loading-container .spinner { 
    border: 4px solid #f3f3f3; 
    border-top: 4px solid #3498db; 
    border-radius: 50%; 
    width: 40px; 
    height: 40px; 
    animation: spin 1s linear infinite; 
    margin: 20px auto 20px; 
    display: block; 
}
@keyframes spin { 0% { transform: rotate(0) } 100% { transform: rotate(360deg) } }

/* [UPDATED] Interface Container: Uses 100% height to respect PHP parent constraints */
.ielts-main-interface-container { 
    display: none; 
    flex-direction: column; 
    height: 100%; 
    position: relative; 
    z-index: 1; 
    padding-bottom: var(--footer-height); 
    min-height: 0;
    box-sizing: border-box;
    overflow: hidden !important; /* Critical for preventing footer push */
}

.ielts-final-wrapper.test-loading .ielts-widget-header,
.ielts-final-wrapper.test-loading .ielts-prestart-screen { display: none; }
.ielts-final-wrapper.test-loading .ielts-loading-container { display: flex; }
.ielts-final-wrapper.test-started .ielts-widget-header,
.ielts-final-wrapper.test-started .ielts-prestart-screen { display: none; }
.ielts-final-wrapper.test-started .ielts-loading-container { display: none; }
.ielts-final-wrapper.test-started .ielts-main-interface-container { display: flex; }
.ielts-final-wrapper.test-completed .ielts-main-interface-container, .ielts-final-wrapper.test-completed .ielts-pagination-footer, .ielts-final-wrapper.test-completed .ielts-widget-header, .ielts-final-wrapper.test-completed .ielts-loading-container, .ielts-final-wrapper.test-completed .ielts-prestart-screen { display: none; }
.ielts-final-wrapper.test-completed .ielts-results-container { display: block; }

/* Focus Mode */
.ielts-final-wrapper.focus-mode { position: fixed; inset: 0; width: 100%; height: 100vh; max-width: none; margin: 0; background: #ffffff; z-index: var(--ielts-lms-z-focus, 9999); padding: 0; box-sizing: border-box; border: none; border-radius: 0; display: flex; flex-direction: column; overflow: hidden; }
.ielts-final-wrapper.focus-mode .ielts-main-interface-container { height: 100%; max-height: none; flex-grow: 1; padding-bottom: var(--footer-height); min-height: 0; box-sizing: border-box; }
.ielts-final-wrapper.focus-mode .ielts-main-interface-container,
.ielts-final-wrapper.focus-mode .ielts-writing-container {
    width: 100%;
    border-radius: 0 !important;
}

.ielts-final-wrapper.focus-mode .ielts-top-bar,
.ielts-final-wrapper.focus-mode .ielts-widget-header {
    margin-top: 0 !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}

.ielts-final-wrapper.focus-mode {
    inset: var(--wp-admin--admin-bar--height, 0px) 0 0 0;
    height: calc(100vh - var(--wp-admin--admin-bar--height, 0px));
}

.ielts-final-wrapper.focus-mode.test-completed {
    overflow: auto;
}

/* Hide overflow in runtime shell fullscreen mode only */
body.ielts-mock-standalone--runtime.ielts-focus-active { overflow: hidden; }
/* Allow scrolling in shortcode and hub contexts */
body.ielts-focus-active:not(.ielts-mock-standalone--runtime) { overflow: auto; }

/* --- 6. TOP BAR --- */
.ielts-top-bar {
    display: flex; justify-content: space-between; align-items: center;
    height: 68px; background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%); padding: 0 24px;
    border-bottom: 1px solid #e2e8f0; box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    position: relative; z-index: 2000; gap: 20px; font-family: var(--ielts-lms-font-sans, 'Inter', sans-serif);
    margin-bottom: 0; flex-shrink: 0;
}
.ielts-top-bar-left { flex: 1; overflow: hidden; display: flex; align-items: center; }
.ielts-top-bar-title { font-size: clamp(17px, 1vw, 18px); font-weight: 800; color: #0f172a; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ielts-top-bar-brandline { display: flex; align-items: center; gap: 14px; min-width: 0; max-width: 100%; }
.ielts-top-bar-brand { flex: 0 0 auto; display: inline-flex; align-items: center; }
.ielts-top-bar-brand-image { display: block; width: auto; max-width: 92px; max-height: 27px; object-fit: contain; }
.ielts-top-bar-brandline .ielts-top-bar-title { display: block; min-width: 0; }
.ielts-top-bar-center { flex: 0 0 auto; display: flex; justify-content: center; align-items: center; }

.ielts-timer-display { 
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%); color: #334155; padding: 6px 18px;
    border-radius: 999px; border: 1px solid #dbe4ef;
    font-size: 16px; font-weight: 700; font-family: var(--ielts-lms-font-mono, 'Roboto Mono', monospace);
    display: flex; align-items: center; gap: 10px; 
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}
.ielts-timer-display svg { stroke: #dc3545; width: 20px; height: 20px; }
.ielts-top-bar-right { flex: 2; display: flex; justify-content: flex-end; align-items: center; gap: 12px; z-index: 20; }

.ielts-notes-toggle-btn { 
    min-height: 42px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%); border: 1px solid #dbe4ef;
    color: #334155; font-size: 14px; font-weight: 700; border-radius: 10px;
    padding: 0 16px; cursor: pointer; display: inline-flex;
    align-items: center; justify-content: center; gap: 8px; 
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 180ms ease, box-shadow 180ms ease;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06); position: relative;
}
.ielts-notes-toggle-btn:hover { background: #ffffff; border-color: #94a3b8; color: #0f172a; transform: translateY(-1px); box-shadow: 0 10px 20px rgba(15, 23, 42, 0.1); }
.ielts-notes-toggle-btn.has-new-notes::after { content: ""; position: absolute; top: 5px; right: 5px; width: 10px; height: 10px; background-color: #dc3545; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.1); }
.ielts-notes-toggle-btn svg { width: 16px; height: 16px; stroke-width: 2px; }
.icon-btn-toggle {
    min-height: 42px;
    min-width: 42px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #dbe4ef;
    color: #334155;
    font-size: 14px;
    font-weight: 700;
    border-radius: 10px;
    padding: 0 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 180ms ease, box-shadow 180ms ease;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}
.icon-btn-toggle:hover { background: #ffffff; border-color: #94a3b8; color: #0f172a; transform: translateY(-1px); box-shadow: 0 10px 20px rgba(15, 23, 42, 0.1); }
.icon-btn-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25); }
.icon-btn-toggle:active { transform: scale(0.97); }
#font-toggle-btn { width: 42px; padding: 0; border-radius: 50%; margin-left: 4px; }
.icon-btn-label { display: none; }
.icon-btn-menu .ielts-options-icon { width: 18px; height: 18px; }
.ielts-options-icon-moon,
.ielts-options-icon-sun { display: none; }
.font-popup { display: none; position: fixed; inset: 0; background: rgba(255, 255, 255, 0.96); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); padding: 32px 20px; align-items: flex-start; justify-content: center; overflow-y: auto; z-index: 1000; }
.font-popup.active { display: flex; }
.ielts-final-wrapper.writing-mode .font-popup {
    background: #ffffff;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    z-index: 2100;
}
.options-popup { min-width: 0; width: 100%; }
.ielts-options-dialog { width: min(100%, 700px); display: flex; flex-direction: column; gap: 22px; }
.ielts-options-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ielts-options-title { margin: 0; flex: 1; text-align: center; font-size: 25px; font-weight: 500; color: #111827; }
.ielts-options-close-btn { width: 40px; height: 40px; border: 0; border-radius: 999px; background: transparent; color: #111827; font-size: 34px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.ielts-options-content { display: flex; flex-direction: column; gap: 16px; }
.ielts-options-panel { display: none; flex-direction: column; gap: 14px; width: 100%; }
.ielts-options-panel.active { display: flex; }
.ielts-options-hero-button { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; min-height: 72px; padding: 18px 24px; border: 0; border-radius: 6px; background: #ea1636; color: #ffffff; font: inherit; font-size: 20px; font-weight: 500; cursor: pointer; box-shadow: 0 18px 38px rgba(234, 22, 54, 0.22); }
.ielts-options-hero-icon { width: 38px; height: 38px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ielts-options-hero-icon svg { width: 20px; height: 20px; }
.ielts-options-hero-label { flex: 1; text-align: left; }
.ielts-options-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 72px; border-radius: 6px; }
.ielts-options-item-button { border: 1px solid #dbe4ef; background: #ffffff; color: #0f172a; font: inherit; font-size: 18px; font-weight: 500; padding: 18px 24px; cursor: pointer; transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 180ms ease, transform 180ms ease; box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06); }
.ielts-options-item-button:hover { background: #f8fafc; border-color: #cbd5e1; color: #0f172a; transform: translateY(-1px); box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1); }
.ielts-options-item-button.active { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.ielts-options-item-copy { display: flex; align-items: center; gap: 16px; min-width: 0; }
.ielts-options-item-icon { width: 38px; height: 38px; border-radius: 999px; background: #eef4fa; color: #0f172a; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ielts-options-item-icon svg { width: 20px; height: 20px; }
.ielts-options-item-label { white-space: nowrap; }
.ielts-options-item-chevron { font-size: 26px; line-height: 1; color: currentColor; }
.ielts-options-back-btn { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; padding: 0; border: 0; background: transparent; color: #0f172a; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.ielts-options-back-icon { font-size: 18px; line-height: 1; }
.ielts-options-subheader { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; max-width: 520px; margin: 0 auto; }
.ielts-options-subheader-title { flex: 1; text-align: center; font-size: 18px; font-weight: 500; color: #111827; margin: 0; }
.ielts-sub-close-btn { width: 28px; height: 28px; font-size: 24px; }
.ielts-preset-list { display: flex; flex-direction: column; width: 100%; max-width: 700px; margin: 0 auto; border: 1px solid #d1d7e0; border-radius: 4px; overflow: hidden; }
.font-popup.ielts-subpanel-active { padding: 0; background: #ffffff; -webkit-backdrop-filter: none; backdrop-filter: none; }
.font-popup.ielts-subpanel-active .ielts-options-dialog { width: 100%; max-width: none; gap: 0; }
.font-popup.ielts-subpanel-active .ielts-options-header { display: none; }
.font-popup.ielts-subpanel-active .ielts-options-content { gap: 0; }
.font-popup.ielts-subpanel-active .ielts-options-panel.active { gap: 14px; }
.font-popup.ielts-subpanel-active .ielts-options-subheader { width: 100%; max-width: none; min-height: 80px; margin: 0; padding: 0 13px 0 0; box-sizing: border-box; gap: 12px; align-items: flex-start; }
.font-popup.ielts-subpanel-active .ielts-options-subheader-title { align-self: flex-start; margin-top: 21px; font-size: 27.2px; font-weight: 400; line-height: 1.15; }
.font-popup.ielts-subpanel-active .ielts-options-back-btn { align-self: flex-start; margin-top: 16px; gap: 8px; padding: 0 0 0 2px; font-size: 27.2px; font-weight: 400; line-height: 1; }
.font-popup.ielts-subpanel-active .ielts-options-back-icon { font-size: 27.2px; line-height: 1; }
.font-popup.ielts-subpanel-active .ielts-sub-close-btn { align-self: flex-start; width: 66.6667px; height: 66.6667px; font-size: 26.6667px; line-height: 1; }
.font-popup.ielts-subpanel-active .ielts-preset-list { width: 100%; max-width: 700px; margin: 0 auto; }
.ielts-preset-item { display: flex; align-items: center; gap: 16px; width: 100%; padding: 25px 34px; border: none; border-bottom: 1px solid #e5e7eb; background: #ffffff; color: #111827; font: inherit; font-size: 17px; font-weight: 400; text-align: left; cursor: pointer; transition: background-color 120ms ease; }
.ielts-preset-item:last-child { border-bottom: none; }
.ielts-preset-item:hover { background: #f3f4f6; }
.ielts-preset-check { display: none; font-size: 21px; font-weight: 700; color: #111827; width: auto; flex-shrink: 0; }
.ielts-preset-item.active .ielts-preset-check { display: inline-block; }
.ielts-preset-item.active { background: #ffffff; color: #111827; border-color: transparent; border-bottom: 1px solid #e5e7eb; }
.ielts-preset-item.active:last-child { border-bottom: none; }
.ielts-preset-label { flex: 1; }
.ielts-contrast-preview { display: flex; flex-direction: column; gap: 4px; width: 57px; height: 38px; box-sizing: border-box; border-radius: 4px; padding: 6px 7px; justify-content: center; flex-shrink: 0; border: 1px solid #d1d7e0; }
.ielts-contrast-preview span { display: block; height: 3px; border-radius: 2px; }
.ielts-contrast-preview-bow { background: #ffffff; }
.ielts-contrast-preview-bow span { background: #333333; }
.ielts-contrast-preview-wob { background: #1a1a1a; border-color: #1a1a1a; }
.ielts-contrast-preview-wob span { background: #ffffff; }
.font-popup.ielts-subpanel-active .ielts-text-size-preset { border: none; border-radius: 0; background: #ffffff; color: #111827; font-size: 17px; font-weight: 400; padding: 25px 34px; }

.ielts-final-answer-button { 
    -webkit-appearance: none;
    appearance: none;
    min-height: 44px;
    padding: 0 22px;
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    font-family: var(--ielts-lms-font-sans, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif);
    font-size: 15px;
    line-height: 1;
    font-weight: 700;
    letter-spacing: -0.01em;
    border: 1px solid #1d4ed8;
    border-radius: 12px;
    cursor: pointer;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.24);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.ielts-final-answer-button:hover { background: linear-gradient(180deg, #1d4ed8 0%, #1e40af 100%); border-color: #1e40af; box-shadow: 0 14px 28px rgba(30, 64, 175, 0.28); transform: translateY(-1px); }
.ielts-final-answer-button:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.22); outline-offset: 2px; }

/* --- 7. WRITING SPECIFIC: SPLIT LAYOUT --- */
.ielts-writing-container { 
    display: flex; flex-direction: row; flex-grow: 1; 
    border-radius: 0; box-shadow: none; 
    overflow: hidden; position: relative; background: #fff; border-top: none; 
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
}
.ielts-task-intro-shell {
    padding: 14px 14px 0;
    background: #ffffff;
}
.ielts-task-intro-panel {
    display: none;
    padding: 12px 16px;
    border: 1px solid #d5d5d5;
    border-radius: 4px;
    background: #f1f2ec;
}
.ielts-task-intro-panel.active {
    display: block;
}
.ielts-writing-panel { 
    display: flex; 
    flex-direction: column; 
    background: #ffffff; 
    min-width: 0; 
    overflow: hidden; /* Prevent content-driven expansion */
    height: 100%; /* [UPDATED] Force height compliance */
}
#ielts-left-panel { 
    width: 45%; 
    z-index: 1; 
    position: relative; 
    border-right: 0; 
    flex-shrink: 0; /* Important: Do not allow the right panel to squish this */
}
#ielts-right-panel { 
    flex-grow: 1; 
    z-index: 1; 
    position: relative; 
    min-width: 0; /* Allow the panel to be smaller than its content if flex dictates */
}

.ielts-task-content-wrapper { padding: 24px 24px calc(var(--footer-height) + 24px); overflow-y: auto; flex-grow: 1; min-height: 0; box-sizing: border-box; }
.ielts-task-content { display: none; -webkit-user-select: text !important; user-select: text !important; }
.ielts-task-content.active { display: block; animation: fadeIn 0.3s ease; }
.ielts-task-header { font-size: 13px; font-weight: 600; color: #7c8596; text-transform: uppercase; margin-bottom: 15px; letter-spacing: 0.05em; }
.ielts-task-intro-title {
    margin: 0 0 4px;
    font-size: 16px;
    line-height: 1.3;
    font-weight: 700;
    color: #111111;
}
.ielts-task-intro-copy {
    margin: 0;
    font-size: 16px;
    line-height: 24px;
    font-weight: 400;
    color: #111111;
}
.ielts-task-prompt { font-size: 18px; line-height: 1.7; color: #0f172a; }

/* Heading hierarchy inside the writing task prompt (answer box excluded) */
.ielts-task-prompt h1 { font-size: 2.2em; font-weight: 700; line-height: 1.2; margin-bottom: 0.5em; display: block; }
.ielts-task-prompt h2 { font-size: 1.8em; font-weight: 700; line-height: 1.2; margin-bottom: 0.5em; display: block; }
.ielts-task-prompt h3 { font-size: 1.5em; font-weight: 700; line-height: 1.3; margin-bottom: 0.5em; display: block; }
.ielts-task-prompt h4 { font-size: 1.3em; font-weight: 700; line-height: 1.4; margin-bottom: 0.5em; display: block; }
.ielts-task-prompt h5 { font-size: 1.1em; font-weight: 700; line-height: 1.4; margin-bottom: 0.5em; display: block; }
.ielts-task-prompt h6 { font-size: 1.0em; font-weight: 700; line-height: 1.4; margin-bottom: 0.5em; display: block; }
.ielts-task-prompt b,
.ielts-task-prompt strong { font-weight: 700; color: inherit; }
.ielts-task-image-container { margin-top: 15px; text-align: center; }
.ielts-task-image-container img { max-width: 100%; border-radius: 0; border: 0; height: auto; } 

/* Editor Box */
.ielts-answer-area { 
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    min-height: 0;
    padding: 14px 14px calc(var(--footer-height) + 14px);
    box-sizing: border-box;
    overflow: hidden; /* [UPDATED] Contain children to trigger scrolling */
}
.ielts-writing-box { 
    display: none; 
    flex-direction: column; 
    flex: 1; 
    min-height: 0; /* [UPDATED] Critical for flexbox scrolling */
    width: auto; 
}
.ielts-writing-box.active { display: flex; border: 1px solid #22c55e; border-radius: 0; box-sizing: border-box; margin: 0; overflow: hidden; background: #fff; }
.editor-header-label { padding: 12px 20px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; border-bottom: 1px solid #e5e7eb; background: #ffffff; }

/* Quill Styles */
.quill-wrapper { 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    height: 100%; 
    min-height: 0; /* [UPDATED] Critical */
}
.ielts-writing-box .ql-toolbar { display: none; } 
.ielts-writing-box .ql-container { font-size: 17px; font-family: 'Georgia', serif; flex-grow: 1; height: 100%; overflow: hidden; border: none !important; padding: 0; -webkit-user-select: text !important; user-select: text !important; line-height: 1.8; }
.ielts-writing-box .ql-editor { 
    height: 100%; 
    overflow-y: auto; 
    padding: 20px 20px calc(var(--footer-height) + 20px); 
    word-wrap: break-word; /* Ensure wrapping of long strings */
    overflow-wrap: break-word;
}
.ielts-writing-box .ql-editor.ql-blank::before { font-family: 'Inter', sans-serif; color: #cbd5e1; font-style: italic; }
.ielts-writing-box .ielts-plain-editor {
    width: 100%;
    height: 100%;
    min-height: 260px;
    border: none;
    outline: none;
    resize: none;
    overflow-y: auto;
    padding: 20px 20px calc(var(--footer-height) + 20px);
    background: #fff;
    color: #334155;
    font-family: 'Georgia', serif;
    font-size: 17px;
    line-height: 1.8;
    box-sizing: border-box;
}
.ielts-writing-box .ielts-plain-editor::placeholder {
    font-family: 'Inter', sans-serif;
    color: #cbd5e1;
    font-style: italic;
}
.ielts-final-wrapper.writing-mode.ielts-text-size-regular .ielts-task-prompt { font-size: 18px; }
.ielts-final-wrapper.writing-mode.ielts-text-size-large .ielts-task-prompt { font-size: 20px; }
.ielts-final-wrapper.writing-mode.ielts-text-size-extra-large .ielts-task-prompt { font-size: 22px; }
.ielts-final-wrapper.writing-mode.ielts-text-size-regular .ielts-writing-box .ielts-plain-editor,
.ielts-final-wrapper.writing-mode.ielts-text-size-regular .ielts-review-content .ql-editor { font-size: 16px; }
.ielts-final-wrapper.writing-mode.ielts-text-size-large .ielts-writing-box .ielts-plain-editor,
.ielts-final-wrapper.writing-mode.ielts-text-size-large .ielts-review-content .ql-editor { font-size: 18px; }
.ielts-final-wrapper.writing-mode.ielts-text-size-extra-large .ielts-writing-box .ielts-plain-editor,
.ielts-final-wrapper.writing-mode.ielts-text-size-extra-large .ielts-review-content .ql-editor { font-size: 20px; }
.ielts-final-wrapper.writing-mode.ielts-high-contrast,
.ielts-final-wrapper.writing-mode.ielts-high-contrast.focus-mode,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-main-interface-container,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-writing-container,
.ielts-final-wrapper.writing-mode.ielts-high-contrast #ielts-left-panel,
.ielts-final-wrapper.writing-mode.ielts-high-contrast #ielts-right-panel { background: #101010 !important; color: #f5f5f5 !important; }
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-top-bar,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-timer-display,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-notes-toggle-btn,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .icon-btn-toggle,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-final-answer-button,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .options-popup,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-writing-box.active,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .editor-header-label,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-task-content-wrapper,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-writing-toolbar,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-notes-sidebar,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .notes-search-box,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .note-item,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-pagination-footer,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .part-box { background: #161616 !important; color: #f5f5f5 !important; border-color: #5b6470 !important; box-shadow: none !important; }
.ielts-final-wrapper.writing-mode.ielts-high-contrast .box-summary-text,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .part-text,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .active-label { color: #f5f5f5 !important; }
.ielts-final-wrapper.writing-mode.ielts-high-contrast .part-box.active::before { background: #f5f5f5 !important; }
.ielts-final-wrapper.writing-mode.ielts-high-contrast .part-box:hover { background: #222222 !important; }
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-top-bar-title,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-task-header,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-task-prompt,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-task-prompt strong,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-task-prompt b,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .editor-header-label,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-writing-toolbar,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .notes-sidebar-header h3,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .note-item-text,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .note-item-context,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .part-box,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-title,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-back-btn,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-subheader-title,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-item-button,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-preset-item,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-preset-check,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-preset-label { color: #f5f5f5 !important; }
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-plain-editor,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-review-content .ql-editor,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .notes-search-box input { background: #101010 !important; color: #f5f5f5 !important; border-color: #5b6470 !important; caret-color: #f5f5f5; }
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-plain-editor::placeholder,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .notes-search-box input::placeholder { color: #94a3b8 !important; }
.ielts-final-wrapper.writing-mode.ielts-high-contrast .font-popup,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .font-popup.ielts-subpanel-active,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .options-popup,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-dialog,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-panel,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-content,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-header,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-subheader,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-preset-list {
    background: #000000 !important;
    color: #f5f5f5 !important;
    border-color: #353535 !important;
    box-shadow: none !important;
}
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-hero-button {
    background: #2bd4c3 !important;
    border: 1px solid #2bd4c3 !important;
    color: #000000 !important;
    box-shadow: none !important;
}
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-hero-icon,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-item-icon {
    background: transparent !important;
    color: inherit !important;
}
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-item-button,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-preset-item,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .font-popup.ielts-subpanel-active .ielts-text-size-preset {
    background: #000000 !important;
    color: #f5f5f5 !important;
    border-color: #353535 !important;
    box-shadow: none !important;
}
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-item-button:hover,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-preset-item:hover,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .font-popup.ielts-subpanel-active .ielts-text-size-preset:hover {
    background: #0f0f0f !important;
    border-color: #4b4b4b !important;
    box-shadow: none !important;
    transform: none !important;
}
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-preset-item.active,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .font-popup.ielts-subpanel-active .ielts-text-size-preset.active {
    background: #000000 !important;
    color: #f5f5f5 !important;
    border-color: #353535 !important;
    box-shadow: none !important;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-task-intro-card {
    background: #111111 !important;
    border-color: #353535 !important;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-task-intro-shell {
    background: #000000 !important;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-task-intro-panel {
    background: #111111 !important;
    border-color: #353535 !important;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-task-intro-title,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-task-intro-copy {
    color: #f5f5f5 !important;
}
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-close-btn,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-sub-close-btn,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-item-chevron,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-back-icon,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-title,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-back-btn,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-subheader-title,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-preset-check,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-preset-label,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-options-item-label {
    color: #f5f5f5 !important;
}
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-preset-check {
    font-weight: 700;
}
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-contrast-preview {
    border-color: #5b6470 !important;
}
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-contrast-preview-bow {
    background: #ffffff !important;
    border-color: #5b6470 !important;
}
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-contrast-preview-bow span {
    background: #1a1a1a !important;
}
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-contrast-preview-wob {
    background: #111111 !important;
    border-color: #5b6470 !important;
}
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-contrast-preview-wob span {
    background: #ffffff !important;
}
.ielts-writing-toolbar { 
    padding: 10px 20px; 
    border-top: 1px solid #e5e7eb; 
    background: #ffffff; 
    text-align: right; 
    font-size: 13px; 
    color: #64748b; 
    font-weight: 600; 
    position: relative; 
    z-index: 2; 
    flex-shrink: 0; /* [UPDATED] Prevents toolbar from being squashed */
}

/* Dragger & Shield */
.ielts-writing-dragger { flex-basis: 6px; flex-shrink: 0; background: #f1f5f9; cursor: col-resize; border-left: 0; border-right: 0; z-index: 101; position: relative; display: flex; align-items: center; justify-content: center; }
.ielts-writing-dragger:hover { background: #e5e7eb; }
.ielts-writing-dragger::before { content: ''; width: 4px; height: 20px; border-left: 2px dotted #cbd5e1; }
.ielts-drag-shield { display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; cursor: col-resize; background: transparent; }

/* --- 8. FOOTER --- */
.ielts-pagination-footer { 
    position: fixed; bottom: 0; left: 0; width: 100%; height: 53px; 
    background-color: #ffffff; box-shadow: none; border-top: 1px solid #d9dde5;
    display: flex; align-items: center; justify-content: space-between; 
    padding: 0 1px; gap: 0; z-index: 1000; 
}
.parts-grid { display: flex; flex-grow: 1; width: 100%; gap: 2px; height: 100%; min-width: 0; }
.part-box { 
    flex: 1; width: 0; min-width: 0; height: 100%; border-radius: 0; 
    border: 0; background-color: #fff; overflow: hidden; 
    display: flex; align-items: center; justify-content: center; cursor: pointer; 
    position: relative; transition: background-color 0.25s, color 0.25s;
}
.part-box:hover { background-color: #f7f7f8; }
.part-box.active { 
    flex: 1; background: #f8fafc; box-shadow: none;
    justify-content: center; cursor: default;
}
.part-box.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #111827;
}
.box-summary-text { 
    display: block; font-size: 15px; font-weight: 400; color: #41454f; 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; 
    width: 100%; text-align: center; opacity: 1; transition: opacity 0.2s; 
}
.part-box.active .box-summary-text { display: none; opacity: 0; }
.box-questions-area { display: none; width: 100%; height: 100%; align-items: center; opacity: 0; transition: opacity 0.4s ease 0.1s; }
.part-box.active .box-questions-area { display: flex; opacity: 1; }
.active-label { 
    padding: 0 12px; font-weight: 400; font-size: 15px; color: #111827; 
    white-space: nowrap; flex-shrink: 0; height: 100%; display: flex; align-items: center; 
    width: 100%; justify-content: center;
}

/* --- 9. RESULTS SCREEN --- */
.ielts-results-container { display: none; text-align: center; padding: 20px; flex-shrink: 0; padding-bottom: 60px; }
.ielts-results-title { font-size: 28px; font-weight: 700; color: #1e293b; margin-bottom: 10px; }
.ielts-results-subtitle { font-size: 16px; color: #64748b; margin-bottom: 30px; }
.ielts-final-score-box { font-size: 22px; margin: 20px auto 25px; line-height: 1.6; padding: 20px; background: #f7f8fa; border: 1px solid #e2e8f0; border-radius: 8px; max-width: 400px; }
.ielts-final-score-box .band-score { font-size: 1.3em; font-weight: bold; color: #007BFF; display: block; margin-top: 8px; }

/* Review Area */
.ielts-review-area { display: flex; flex-direction: column; gap: 30px; text-align: left; }
.ielts-review-task { border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.02); }
.ielts-review-header { background: #f8fafc; padding: 15px 25px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: flex-start; align-items: center; gap: 16px; flex-wrap: wrap; }
.ielts-review-header h3 { margin: 0; font-size: 18px; font-weight: 700; color: #334155; }
.ielts-review-header-tools { margin-left: auto; display: flex; align-items: center; justify-content: flex-end; gap: 14px; flex-wrap: wrap; }
.ielts-review-word-count { font-size: 13px; background: #fff; padding: 5px 10px; border-radius: 6px; border: 1px solid #cbd5e1; color: #475569; font-weight: 600; }
.ielts-review-split { display: flex; min-height: 300px; align-items: stretch; }
.review-prompt-side { width: 40%; padding: 25px; border-right: 1px solid #e2e8f0; background: #fdfdfd; max-height: 600px; overflow-y: auto; }
.review-prompt-side img { max-width: 100%; height: auto; border: 1px solid #e2e8f0; border-radius: 4px; margin-top: 10px; display: block; }
.review-answer-side { width: 60%; padding: 25px; background: #fff; max-height: 600px; overflow-y: auto; }
.review-prompt-side h4, .review-answer-side h4 { margin-top: 0; font-size: 12px; text-transform: uppercase; color: #94a3b8; margin-bottom: 15px; letter-spacing: 0.05em; font-weight: 700; border-bottom: 2px solid #f1f5f9; padding-bottom: 8px; display: inline-block; }
.ielts-review-content .ql-editor { padding: 0; font-family: 'Georgia', serif; font-size: 17px; color: #334155; line-height: 1.8; -webkit-user-select: text !important; user-select: text !important; overflow-y: visible; }
.ielts-review-content { white-space: pre-wrap; word-break: break-word; }
.ielts-results-nav { margin-top: 30px; display: flex; justify-content: center; gap: 15px; }

/* ── Solution Bar ─────────────────────────────────────────────────── */
.ielts-solution-bar {
    margin: 0;
    padding: 0;
    background: transparent;
    border-top: none;
}
.solution-bar-label {
    display: none;
}
.solution-bar-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
}
.ielts-solution-btn {
    padding: 7px 16px;
    border-radius: 999px;
    border: 1.5px solid #5b6cff;
    background: #fff;
    color: #4f46e5;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s, box-shadow .15s, transform .15s;
    box-shadow: 0 4px 10px rgba(91,108,255,.08);
}
.ielts-solution-btn:hover,
.ielts-solution-btn.is-active {
    background: #5b6cff;
    color: #fff;
    box-shadow: 0 12px 24px rgba(91,108,255,.18);
    transform: translateY(-1px);
}
.solution-accordion {
    margin-top: 12px;
    border-top: 1px solid #e2e8f0;
    padding-top: 12px;
}
.accordion-inner {
    font-size: 15px;
    line-height: 1.75;
    color: #1e293b;
}
.accordion-inner p { margin: 0 0 10px; }
.accordion-inner ul, .accordion-inner ol { padding-left: 20px; margin: 0 0 10px; }

/* ── AI Feedback Box ──────────────────────────────────────────────── */
.ielts-ai-feedback-box {
    margin-top: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    overflow: hidden;
}
.ai-feedback-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}
.ai-feedback-label {
    font-size: 13px;
    font-weight: 700;
    color: #475569;
}
.btn-task-refresh {
    padding: 4px 12px;
    border-radius: 16px;
    border: 1.5px solid #6366f1;
    background: #fff;
    color: #6366f1;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.btn-task-refresh:hover { background: #6366f1; color: #fff; }
.btn-task-refresh:disabled { opacity: .65; cursor: wait; }

/* State visibility */
.ai-feedback-idle-msg,
.ai-feedback-loading,
.ai-feedback-body,
.ai-feedback-error { display: none; padding: 12px 14px; }

.feedback-state-idle   .ai-feedback-idle-msg  { display: block; font-size: 13px; color: #64748b; }
.feedback-state-loading .ai-feedback-loading  { display: block; }
.feedback-state-done   .ai-feedback-body      { display: block; font-size: 15px; line-height: 1.75; color: #1e293b; }
.feedback-state-error  .ai-feedback-error     { display: block; color: #dc2626; font-size: 13px; }

.ai-feedback-rendered { display: grid; gap: 14px; }
.ai-feedback-meta {
    font-size: 12px;
    font-weight: 600;
    color: #6366f1;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.ai-feedback-score-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.ai-feedback-score-card {
    padding: 12px 14px;
    border: 1px solid #dbe4ff;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
}
.ai-feedback-score-card-overall {
    grid-column: 1 / -1;
    border-color: #c7d2fe;
    background: linear-gradient(180deg, #eef2ff 0%, #ffffff 100%);
}
.ai-feedback-score-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.ai-feedback-score-card strong {
    font-size: 20px;
    line-height: 1.1;
    color: #1e293b;
}
.ai-feedback-section h5 {
    margin: 0 0 8px;
    font-size: 14px;
    color: #0f172a;
}
.ai-feedback-section ul {
    margin: 0;
    padding-left: 18px;
}
.ai-feedback-section li {
    margin-bottom: 6px;
}
.ai-feedback-highlight-list {
    display: grid;
    gap: 10px;
}
.ai-feedback-highlight-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
    padding: 12px;
}
.ai-feedback-highlight-row + .ai-feedback-highlight-row {
    margin-top: 8px;
}
.ai-feedback-highlight-tag {
    display: inline-block;
    min-width: 64px;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6366f1;
}
.ai-inline-highlight {
    background: linear-gradient(180deg, rgba(254, 240, 138, 0.32) 0%, rgba(253, 224, 71, 0.72) 100%);
    border-bottom: 2px solid #f59e0b;
    border-radius: 3px;
    cursor: pointer;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}
.ai-inline-highlight:focus {
    outline: 2px solid #f59e0b;
    outline-offset: 2px;
}
.ielts-ai-highlight-tooltip {
    position: fixed;
    z-index: var(--ielts-lms-z-popup, 10001);
    width: min(360px, calc(100vw - 24px));
    background: #fffdf7;
    border: 1px solid #fde68a;
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
    padding: 14px;
}
.ielts-ai-highlight-tooltip-title {
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 800;
    color: #b45309;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.ielts-ai-highlight-tooltip-row + .ielts-ai-highlight-tooltip-row {
    margin-top: 10px;
}
.ielts-ai-highlight-tooltip-row span {
    display: inline-block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #92400e;
}
.ielts-ai-highlight-tooltip-row div {
    font-size: 13px;
    line-height: 1.55;
    color: #1f2937;
}

/* Shimmer skeleton */
@keyframes ielts-shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}
.skeleton-line {
    display: block;
    height: 14px;
    border-radius: 6px;
    margin-bottom: 10px;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 600px 100%;
    animation: ielts-shimmer 1.4s infinite linear;
}
.skeleton-line.short { width: 55%; }

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-results-title {
    color: #f8fafc;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-results-subtitle {
    color: #cbd5e1;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-review-task {
    background: #0f1115;
    border-color: #353535;
    box-shadow: none;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-review-header {
    background: #090b0f;
    border-bottom-color: #353535;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-review-header h3,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .review-prompt-side h4,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .review-answer-side h4,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ai-feedback-label,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .feedback-state-idle .ai-feedback-idle-msg,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .feedback-state-done .ai-feedback-body,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .feedback-state-error .ai-feedback-error,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ai-feedback-section h5,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ai-feedback-score-card strong,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-review-prompt-box,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-review-prompt-box p,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-review-prompt-box li,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-review-prompt-box strong,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-review-prompt-box b {
    color: #f8fafc;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-review-word-count {
    background: #111827;
    color: #dbeafe;
    border-color: #475569;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .review-prompt-side,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .review-answer-side {
    background: #0f1115;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .review-prompt-side {
    border-right-color: #353535;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .review-prompt-side h4,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .review-answer-side h4 {
    color: #94a3b8;
    border-bottom-color: #1f2937;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-review-prompt-box {
    background: #111827;
    border: 1px solid #353535;
    border-radius: 12px;
    padding: 18px;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .review-prompt-side img {
    border-color: #475569;
    background: #ffffff;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-review-content {
    background: #101010;
    border: 1px solid #353535;
    border-radius: 12px;
    padding: 18px;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-review-content .ql-editor {
    background: transparent !important;
    color: #f8fafc !important;
    border-color: transparent !important;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-ai-feedback-box,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ai-feedback-highlight-card {
    background: #111827;
    border-color: #353535;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ai-feedback-header {
    background: #0b1220;
    border-bottom-color: #353535;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ai-feedback-score-label {
    color: #94a3b8;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ai-feedback-meta,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ai-feedback-highlight-tag {
    color: #a5b4fc;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ai-feedback-score-card {
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    border-color: #334155;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .ai-feedback-score-card-overall {
    background: linear-gradient(180deg, #172554 0%, #0f172a 100%);
    border-color: #4f46e5;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .btn-task-refresh,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-solution-btn {
    background: #0f172a;
    color: #c7d2fe;
    border-color: #5b6cff;
    box-shadow: none;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .btn-task-refresh:hover,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-solution-btn:hover,
.ielts-final-wrapper.writing-mode.ielts-high-contrast .ielts-solution-btn.is-active {
    background: #5b6cff;
    color: #ffffff;
    box-shadow: none;
}

.ielts-final-wrapper.writing-mode.ielts-high-contrast .skeleton-line {
    background: linear-gradient(90deg, #1f2937 25%, #334155 50%, #1f2937 75%);
    background-size: 600px 100%;
}

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .ielts-review-header { align-items: flex-start; }
    .ielts-review-header-tools { width: 100%; justify-content: flex-start; }
    .ielts-solution-bar { width: 100%; }
    .solution-bar-buttons { gap: 8px; }
    .ielts-solution-btn   { padding: 6px 12px; font-size: 12px; }
    .btn-task-refresh     { padding: 3px 10px; font-size: 12px; }
    .ai-feedback-score-grid { grid-template-columns: 1fr; }
}


/* Mobile: single column; desktop (≥ 900px): 2-column side-by-side */
.ielts-prestart-layout {
    display: grid;
    grid-template-columns: 1fr;           /* mobile: single column */
    gap: 24px;
    align-items: start;
    max-width: 1368px;
    margin: 0 auto;
    padding: 20px 20px 24px;
}

/* Desktop (≥ 900px): 2-column layout — matches reading/listening breakpoint */
@media (min-width: 900px) {
    .ielts-prestart-layout {
        grid-template-columns: minmax(0, 1.85fr) minmax(320px, 370px);
        gap: 56px;
    }
}

/* Center the prestart block vertically in standalone writing view. */
body.ielts-standalone-mode .ielts-prestart-layout,
body.ielts-standalone-preview .ielts-prestart-layout {
    min-height: calc(100vh - 120px);
    align-content: center;
}

.ielts-prestart-left {
    min-width: 0;
}

.ielts-prestart-layout--mock {
    display: block;
    max-width: 740px;
    gap: 0;
    padding: 0;
    background: #ffffff;
    border: 1px solid #dbe4ef;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.ielts-prestart-layout--mock .ielts-prestart-left {
    max-width: 100%;
    padding: 34px 34px 36px;
}

.ielts-prestart-mock-card-top {
    background: #111827;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    padding: 18px 18px 17px;
    text-align: center;
}

.ielts-prestart-mock-actions {
    max-width: 100%;
    margin: 30px auto 0;
    text-align: center;
}

.ielts-prestart-mock-callout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 0 18px;
    color: #2563eb;
    font-size: 14px;
    line-height: 1.6;
}

.ielts-prestart-mock-callout:before {
    content: 'i';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2563eb;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
}

.ielts-prestart-layout--mock .ielts-candidate-error {
    text-align: center;
}

.ielts-prestart-layout--mock .ielts-start-button {
    width: auto;
    min-width: 180px;
    margin: 0 auto;
}

.ielts-prestart-layout--mock .ielts-prestart-heading {
    display: block;
    margin-bottom: 26px;
}

.ielts-prestart-layout--mock .ielts-prestart-title {
    font-size: 2rem;
    margin-bottom: 8px;
}

.ielts-prestart-layout--mock .ielts-prestart-subtitle {
    font-size: 14px;
    color: #334155;
    max-width: none;
}

.ielts-prestart-layout--mock .ielts-instruction-section {
    background: transparent;
    border-left: 0;
    padding: 0;
    margin-bottom: 26px;
}

.ielts-prestart-layout--mock .ielts-instruction-section:last-of-type {
    margin-bottom: 0;
}

.ielts-prestart-layout--mock .ielts-instruction-section h3 {
    margin-bottom: 16px;
}

.ielts-prestart-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

.ielts-prestart-title {
    text-align: left;
    padding: 0;
    margin-bottom: 0;
    font-size: clamp(2rem, 3vw, 2.55rem);
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: #0f2f63;
}

.ielts-prestart-subtitle {
    color: #475569;
    font-size: 17px;
    line-height: 1.6;
    margin: 0;
    text-align: left;
    flex-basis: 100%;
    max-width: 620px;
}

.ielts-prestart-heading .ielts-attempt-badge {
    margin-left: 0;
}

.ielts-instruction-section {
    background: #f8fafc;
    border-left: 4px solid #0f3d75;
    padding: 30px 32px;
    margin-bottom: 20px;
    text-align: left;
}

.ielts-instruction-section h3 {
    margin: 0 0 18px;
    font-size: 18px;
    line-height: 1.3;
    color: #123a75;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.ielts-instruction-section ul {
    margin: 0;
    padding-left: 20px;
    color: #1f2937;
}

.ielts-instruction-section li {
    margin-bottom: 18px;
    line-height: 1.75;
}

.ielts-instruction-section li:last-child {
    margin-bottom: 0;
}

.ielts-prestart-right {
    width: 100%;
    max-width: 370px;
    justify-self: end;
}

.ielts-candidate-card {
    background: #ffffff;
    border: 1px solid #d9e1ea;
    border-radius: 14px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    padding: 32px 30px;
    text-align: left;
    position: sticky;
    top: 24px;
}

.ielts-candidate-card h3 {
    margin: 0 0 20px;
    font-size: 20px;
    font-weight: 800;
    color: #102a43;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.ielts-candidate-fields label {
    display: block;
    margin-bottom: 18px;
}

.ielts-field-label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: #6b7280;
}

.ielts-candidate-name,
.ielts-candidate-id,
.ielts-prestart-screen .ielts-timer-select {
    width: 100%;
    margin-right: 0;
    margin-bottom: 0;
    padding: 13px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 15px;
    color: #1f2937;
    box-sizing: border-box;
    background: #ffffff;
    height: 48px;
}

.ielts-prestart-screen .ielts-start-button {
    width: 100%;
    min-height: 44px;
    padding: 15px 18px;
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: linear-gradient(180deg,#27c184 0%,#1eb06f 100%);
    border-radius: 6px;
}

.ielts-prestart-screen .ielts-start-button:hover {
    background: linear-gradient(180deg,#27c184 0%,#1eb06f 100%);
}

.ielts-candidate-error {
    margin: 4px 0 14px;
    color: #dc2626;
    font-size: 14px;
    font-weight: 600;
}

.ielts-prestart-support {
    margin: 18px 0 0;
    font-size: 12px;
    line-height: 1.6;
    color: #94a3b8;
    font-style: italic;
    text-align: center;
    max-width: 270px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 900px) {
    .ielts-prestart-layout {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .ielts-prestart-right {
        max-width: 100%;
        justify-self: stretch;
    }

    .ielts-candidate-card {
        position: static;
    }
}

@media (max-width: 768px) {
    body.ielts-standalone-mode .ielts-prestart-layout,
    body.ielts-standalone-preview .ielts-prestart-layout {
        min-height: 0;
        align-content: start;
    }

    .ielts-prestart-layout {
        gap: 20px;
        padding: 12px 0 8px;
    }

    .ielts-prestart-heading {
        gap: 10px;
        margin-bottom: 20px;
    }

    .ielts-candidate-card {
        padding: 26px 22px;
    }

    .ielts-instruction-section {
        padding: 24px 20px;
    }
}

/* AI Button */
#ielts-combined-feedback-btn { background-color: #28a745; color: #fff; border: none; padding: 12px 30px; font-size: 18px; font-weight: 600; border-radius: 8px; cursor: pointer; transition: background-color .2s; margin-bottom: 25px; display: inline-block; }
#ielts-combined-feedback-btn:hover { background-color: #218838; }

.ielts-writing-review-top-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
    margin: 0 0 25px;
}

.ielts-writing-review-top-actions #ielts-combined-feedback-btn {
    margin-bottom: 0;
}

.ielts-writing-review-top-actions .ielts-explanations-toggle-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border: 1px solid #22c55e;
    border-radius: 999px;
    background: #f3f4f6;
    height: 28px;
    box-sizing: border-box;
    transition: background-color .2s ease, border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}

.ielts-writing-review-top-actions .ielts-explanations-toggle-wrap:hover {
    background: #eef2f7;
    border-color: #94a3b8;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.ielts-writing-review-top-actions .ielts-explanations-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    font-weight: 800;
}

.ielts-writing-review-top-actions .ielts-explanations-toggle {
    width: 36px;
    height: 18px;
    border: 0;
    border-radius: 999px;
    background: #cbd5e1;
    position: relative;
    cursor: pointer;
    transition: background .2s ease, box-shadow .2s ease;
}

.ielts-writing-review-top-actions .ielts-explanations-toggle:hover {
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
}

.ielts-writing-review-top-actions .ielts-explanations-toggle .ielts-explanations-knob {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: transform .2s ease;
}

.ielts-writing-review-top-actions .ielts-explanations-toggle.active {
    background: #22c55e;
}

.ielts-writing-review-top-actions .ielts-explanations-toggle.active .ielts-explanations-knob {
    transform: translateX(18px);
}

/* --- 10. MODALS --- */

/* Success Gate */

/* Shared Modal Utilities */

/* AI Popups */
#ielts-solution-modal { background: rgba(15, 23, 42, 0.48); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
#ielts-solution-modal .ielts-solution-modal-content { width: min(100% - 32px, 920px); min-width: 0; max-height: 88vh; padding: 34px 28px 28px; border-radius: 22px; text-align: left; box-shadow: 0 28px 64px rgba(15, 23, 42, 0.28); }
#ielts-solution-modal .ielts-modal-close-btn { position: absolute; right: 18px; top: 14px; font-size: 30px; color: #94a3b8; }
#ielts-solution-modal .ielts-modal-close-btn:hover { color: #334155; }
.ielts-solution-modal-kicker { margin-bottom: 8px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #4f46e5; }
.ielts-solution-modal-title { margin: 0 0 18px; font-size: 18px; line-height: 1.2; font-weight: 700; color: #343a40; font-family: 'Segoe UI', Tahoma, Arial, sans-serif; }
.ielts-solution-modal-body { overflow-y: auto; max-height: calc(88vh - 130px); padding: 22px 24px; border: 1px solid #dbe4f0; border-radius: 18px; background: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.7); font-family: 'Noto Sans', 'Noto Sans Bengali', sans-serif !important; font-size: 16px; line-height: 1.85; font-weight: 500; color: #333; }
.ielts-solution-modal-body p,
.ielts-solution-modal-body li {
    font-size: 1em;
    line-height: 1.85;
}
.ielts-solution-modal-body p:last-child,
.ielts-solution-modal-body ul:last-child,
.ielts-solution-modal-body ol:last-child { margin-bottom: 0; }

.vocab-on .ielts-vocab-word {
    cursor: pointer;
    color: inherit !important;
    font: inherit;
    text-decoration: none;
    background: transparent;
    border-radius: 0;
    transition: text-decoration-color .12s ease, color .12s ease;
}

.vocab-on .ielts-vocab-word:hover,
.vocab-on .ielts-vocab-word:focus {
    color: inherit !important;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
    text-decoration-color: #6366f1;
    outline: none;
}

#ielts-writing-vocab-modal {
    z-index: var(--ielts-lms-z-vocab, 10002);
    background: rgba(15, 23, 42, 0.34);
    -webkit-backdrop-filter: blur(1.8px);
    backdrop-filter: blur(1.8px);
}

#ielts-writing-vocab-modal-card {
    max-width: 430px;
    width: 92vw;
    border-radius: 28px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.26);
    background: #ffffff;
    color: #0f172a;
    overflow: hidden;
    text-align: left;
    padding: 0;
    border: 1px solid #e5e7eb;
}

.ielts-vocab-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 18px 24px 0;
}

.ielts-vocab-pos-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    background: #edf2ff;
    color: #4f46e5;
    font-size: 12px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ielts-vocab-head-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.ielts-vocab-icon-btn {
    border: 0;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    font-size: 28px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ielts-vocab-icon-btn:hover {
    color: #64748b;
}

.ielts-vocab-main {
    padding: 8px 24px 0;
}

.ielts-vocab-word-title {
    margin: 0;
    font-size: 46px;
    line-height: 0.98;
    letter-spacing: -0.03em;
    font-weight: 800;
    color: #0f172a;
}

.ielts-vocab-pronounce-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 9px;
}

#ielts-writing-vocab-phonetic {
    color: #475569;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;
    font-size: 17px;
    letter-spacing: 0.01em;
}

.ielts-vocab-audio-inline-btn {
    border: 0;
    background: transparent;
    color: #4f46e5;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ielts-vocab-audio-inline-btn:hover {
    color: #4338ca;
}

#ielts-writing-vocab-modal-body {
    padding: 18px 24px 16px;
}

.ielts-vocab-section-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-weight: 900;
    color: #94a3b8;
    margin-bottom: 9px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.ielts-vocab-section-label::before {
    content: '';
    width: 11px;
    height: 11px;
    border: 1.6px solid #a8b4c7;
    border-radius: 2px;
    display: inline-block;
    box-sizing: border-box;
}

.ielts-vocab-section-label.is-syn {
    color: #059669;
}

.ielts-vocab-section-label.is-syn::before {
    border-color: #10b981;
    border-radius: 999px;
}

.ielts-vocab-section-label.is-ant {
    color: #f43f5e;
}

.ielts-vocab-section-label.is-ant::before {
    border-color: #f43f5e;
    border-radius: 999px;
}

.ielts-vocab-definition {
    color: #334155;
    font-size: 16px;
    line-height: 1.6;
    font-weight: 600;
    margin-bottom: 18px;
}

.ielts-vocab-example-card {
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    background: #f5f7fb;
    padding: 14px 14px;
    margin-bottom: 18px;
}

.ielts-vocab-example-text {
    color: #475569;
    font-size: 15px;
    line-height: 1.55;
    font-style: italic;
}

.ielts-vocab-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.ielts-vocab-grid.single-col {
    grid-template-columns: 1fr;
}

.ielts-vocab-col {
    min-width: 0;
}

.ielts-vocab-chip-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ielts-vocab-footer {
    background: #f2f5f9;
    border-top: 1px solid #e2e8f0;
    padding: 14px 16px;
}

.ielts-vocab-gotit-btn {
    width: 100%;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(90deg, #4f46e5, #4338ca);
    color: #ffffff;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.02em;
    padding: 15px 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.ielts-vocab-gotit-btn:hover {
    filter: brightness(1.04);
}

.vocab-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 13px;
    line-height: 1.1;
    font-weight: 700;
}

.vocab-chip--syn {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.vocab-chip--ant {
    background: #fff1f2;
    color: #e11d48;
    border: 1px solid #fecdd3;
}

/* Notes Sidebar */
.ielts-notes-sidebar { position: absolute; top: 0; right: -320px; width: 300px; height: 100%; background: #ffffff; border-left: 1px solid #e2e8f0; box-shadow: -2px 0 10px rgba(0,0,0,0.05); z-index: 900; transition: right 0.3s ease; display: flex; flex-direction: column; }
.ielts-notes-sidebar.open { right: 0; }
.notes-sidebar-header { padding: 15px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; background: #f8fafc; }
.notes-sidebar-header h3 { margin: 0; font-size: 16px; font-weight: 700; color: #1e293b; }
#ielts-notes-close-btn { background: none; border: none; font-size: 24px; color: #64748b; cursor: pointer; line-height: 1; }
.notes-search-box { padding: 10px 15px; border-bottom: 1px solid #e2e8f0; position: relative; }
#ielts-notes-search { width: 100%; padding: 8px 10px 8px 30px; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 14px; box-sizing: border-box; }
.notes-search-box svg { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); color: #94a3b8; }
.notes-list-container { flex-grow: 1; overflow-y: auto; padding: 0; }
.note-item { padding: 15px; border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: background 0.15s; display: flex; justify-content: space-between; align-items: center; }
.note-item:hover { background-color: #f8fafc; }
.note-content { flex-grow: 1; overflow: hidden; }
.note-item-text { font-size: 14px; font-weight: 600; color: #334155; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-item-context { font-size: 12px; color: #64748b; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-actions { display: flex; gap: 5px; flex-shrink: 0; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 16px; opacity: 0.6; transition: opacity 0.2s; padding: 2px; }
.icon-btn:hover { opacity: 1; }
.edit-btn { color: #007bff; }
.del-btn { color: #dc3545; }
.no-notes-message { padding: 20px; text-align: center; color: #94a3b8; font-size: 14px; font-style: italic; }

/* Selection Popups */
#text-action-popup { position: fixed; display: none; background: #333; border-radius: 5px; padding: 5px; z-index: var(--ielts-lms-z-popup, 10001); gap: 5px; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
#text-action-popup button { background: #555; color: #fff; border: none; padding: 8px 12px; border-radius: 3px; cursor: pointer; font-size: 14px; }
#text-action-popup button:hover { background: #007BFF; }
#note-display-tooltip { position: fixed; display: none; background: #222; color: #fff; padding: 10px; border-radius: 5px; font-size: 14px; max-width: 300px; z-index: var(--ielts-lms-z-popup, 10001); pointer-events: none; }
.highlighted-text { background-color: #fef08a !important; color: #1e293b !important; padding: 2px 0; border-radius: 2px; display: inline; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.note-attached { background-color: #bae6fd !important; color: #1e293b !important; border-bottom: 2px solid #0ea5e9; cursor: pointer; display: inline; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

/* Text Selection Popup */
.ielts-text-popup {
    display: none;
    position: fixed;
    z-index: 10000;
    background: #1e293b;
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    align-items: center;
    gap: 4px;
    border: 1px solid #334155;
}
.ielts-text-popup.visible { display: flex; }
.popup-btn {
    background: transparent;
    border: none;
    color: #f8fafc;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s, color 0.2s;
}
.popup-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; }
.popup-btn:hover { background: #334155; color: #38bdf8; }
.popup-divider { width: 1px; height: 18px; background: #475569; margin: 0 4px; }

/* Note Modal */
#ielts-note-modal .ielts-note-modal-content { position: absolute; max-width: 350px; padding: 0; box-shadow: 0 4px 15px rgba(0, 0, 0, .15); }
.ielts-modal-header { margin: 0; padding: 10px 15px; font-size: 16px; font-weight: 600; background: #f7f7f7; border-bottom: 1px solid #eee; cursor: move; }
.ielts-modal-header.drag-handle { cursor: grab; }
.ielts-modal-header.drag-handle:active { cursor: grabbing; }
#ielts-note-textarea { width: auto; height: 120px; border: none; border-bottom: 1px solid #eee; border-radius: 0; padding: 15px; font-size: 15px; resize: vertical; margin: 0; }
.ielts-note-buttons { display: flex; justify-content: flex-end; gap: 10px; padding: 10px 15px; background: #f7f7f7; }
.ielts-note-button { border: none; border-radius: 5px; padding: 8px 16px; font-size: 14px; font-weight: 500; cursor: pointer; }
.ielts-note-button.save { background: #007BFF; color: #fff; }


/* --- 11. MOBILE SPECIFIC OVERRIDES --- */
@media (max-width: 768px) {
        .ielts-top-bar { height: 40px; padding: 0 8px; margin-bottom: 0; }
  .ielts-top-bar-center { order: 1; margin-right: auto; flex-shrink: 0; }
  .ielts-timer-display { background: transparent; border: none; box-shadow: none; padding: 0; font-size: 14px; font-weight: 600; }
  .ielts-timer-display svg { width: 16px; height: 16px; margin-right: 4px; }
  .ielts-top-bar-left { display: none; } 
  .ielts-top-bar-right { order: 2; flex: 0 0 auto; gap: 6px; }
    .ielts-top-bar-brand { display: none !important; }
  
  .ielts-notes-toggle-btn { width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: center; }
  .ielts-notes-toggle-btn svg { transform: scale(0.85); }
  .ielts-notes-toggle-btn span { display: none !important; }
        #font-toggle-btn { display: inline-flex !important; width: 44px; height: 44px; min-height: 44px; margin-left: 0; padding: 0; }
        #font-toggle-btn .ielts-options-icon-menu { display: none; }
        #font-toggle-btn .ielts-options-icon-moon { display: block; }
        #font-toggle-btn .ielts-options-icon-sun { display: none; }
        .ielts-final-wrapper.ielts-high-contrast #font-toggle-btn .ielts-options-icon-moon { display: none; }
        .ielts-final-wrapper.ielts-high-contrast #font-toggle-btn .ielts-options-icon-sun { display: block; }
    .icon-btn-label { display: none; }
  
                .ielts-final-answer-button { min-height: 44px; padding: 0 14px; font-size: 13px; white-space: nowrap; }
  
    /* AI Popup Mobile */
        .ielts-writing-review-top-actions { gap: 8px; margin-bottom: 16px; flex-wrap: nowrap; overflow-x: visible; justify-content: center; padding: 0 4px; }
        .ielts-writing-review-top-actions #ielts-combined-feedback-btn { font-size: 12px; padding: 0 14px; height: 28px; box-sizing: border-box; border-radius: 999px; white-space: nowrap; flex-shrink: 1; min-width: 0; margin-bottom: 0; line-height: 28px; }
        .ielts-writing-review-top-actions .ielts-explanations-toggle-wrap { flex-shrink: 0; }

        /* Review header: row 1 = title + word count, row 2 = solution buttons */
        .ielts-review-header { padding: 10px 14px; gap: 6px 0; align-items: center; }
        .ielts-review-header h3 { font-size: 15px; flex: 1 1 0; min-width: 0; order: 1; }
        .ielts-review-word-count { order: 2; flex: 0 0 auto; }
        .ielts-review-header-tools { order: 3; flex: 0 0 100%; margin-left: 0; justify-content: flex-start; padding: 6px 0 4px; }
        .solution-bar-buttons { overflow-x: auto; flex-wrap: nowrap; justify-content: flex-start; padding-bottom: 2px; gap: 8px; }
        .solution-bar-buttons::-webkit-scrollbar { display: none; }
        .ielts-solution-btn { flex-shrink: 0; }

        /* Results nav: stack buttons on mobile */
        .ielts-results-nav { flex-direction: column; align-items: center; gap: 10px; margin-top: 20px; }
        .ielts-results-nav .ielts-start-button { width: min(100%, 320px); }
    #ielts-solution-modal .ielts-solution-modal-content { width: min(100% - 24px, 640px); padding: 28px 18px 18px; border-radius: 18px; }
        #ielts-writing-vocab-modal-card { width: 95vw; }
        .ielts-vocab-word-title { font-size: 34px; }
        #ielts-writing-vocab-phonetic { font-size: 15px; }
        .ielts-vocab-head,
        .ielts-vocab-main,
        #ielts-writing-vocab-modal-body { padding-left: 18px; padding-right: 18px; }
        .ielts-vocab-footer { padding: 12px 14px; }
        .ielts-vocab-grid { grid-template-columns: 1fr; }
        .ielts-vocab-gotit-btn { font-size: 16px; }
    .ielts-solution-modal-title { font-size: 18px; margin-bottom: 14px; }
    .ielts-solution-modal-body { padding: 16px; max-height: calc(88vh - 116px); }
  /* Mobile Header Override */
  .ielts-widget-header { margin-bottom: 15px; gap: 15px; }
  
  /* --- FIX: MOBILE STACKING ISSUE --- */
  .ielts-header-controls { 
      flex-direction: column; 
      width: 100%; 
      gap: 10px; 
  }
  
  /* Force Button and Badge to width 100% on mobile for consistency */
  .ielts-timer-select { width: 100%; margin-right: 0; }
  /* start-button full-width everywhere EXCEPT inside the review top-actions bar */
  .ielts-start-button { width: 100%; }
  .ielts-writing-review-top-actions .ielts-start-button { width: auto; }

  /* Writing Split Layout Mobile (Stacked) */
  .ielts-final-wrapper .ielts-writing-container { flex-direction: column !important; height: auto !important; }
  .ielts-final-wrapper #ielts-left-panel { display: flex !important; height: 40%; width: 100% !important; flex-shrink: 0; border-right: none !important; border-bottom: 1px solid #e2e8f0; }
  .ielts-final-wrapper .ielts-writing-dragger { display: flex !important; width: 100% !important; height: 6px !important; cursor: row-resize !important; border-left: none !important; border-right: none !important; border-top: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb; touch-action: none; z-index: 50; }
  .ielts-final-wrapper .ielts-writing-dragger::before { transform: none; }
  .ielts-final-wrapper #ielts-right-panel { height: 60%; width: 100% !important; flex-grow: 1; min-height: 200px; }
  .editor-header-label { display: none; }
  .ielts-writing-box.active { margin: 5px; }
  .ielts-final-wrapper.test-started .ielts-main-interface-container { padding-bottom: calc(var(--mobile-footer-height) + 24px) !important; }
  .ielts-notes-sidebar { width: 280px; }
  .ielts-review-split { flex-direction: column; }
  .review-prompt-side, .review-answer-side { width: 100%; border-right: none; border-bottom: 1px solid #e2e8f0; max-height: none; }

  /* --- FOOTER FIX FOR WRITING MOBILE: SHOW BOTH TABS --- */
  .ielts-pagination-footer { height: 50px; padding: 0 5px; }
  
  /* Show BOTH tabs side-by-side */
  .part-box { 
      display: flex !important; 
      flex: 1 !important; 
      width: auto !important;
      border-radius: 8px !important;
      margin: 2px !important;
      justify-content: center !important;
      align-items: center !important;
  }
  
  .part-box.active { 
      background-color: #f0fdf4 !important; 
      border-color: #10b981 !important;
      box-shadow: none !important;
  }
  
  /* Labels */
  .box-summary-text { 
      display: block !important; 
      padding: 0 !important; 
      font-size: 13px !important; 
  }
  
  /* Active Tab Layout Override */
  .box-questions-area { display: none !important; } /* Hide complex track */
  .part-box.active .box-questions-area { display: flex !important; justify-content: center; width: auto !important; }
  
  .active-label { 
      position: static !important; 
      top: auto; left: auto;
      background-color: transparent !important; 
      padding: 0 !important; 
      font-size: 13px !important; 
      line-height: inherit; 
      border: none; 
      color: #10b981; 
      justify-content: center;
  }
  
  /* --- INSTRUCTION ACCORDION MOBILE BOX FIXES (UPDATED) --- */
  .ielts-instruction-wrapper {
      padding: 0 10px !important;
      box-sizing: border-box !important;
      max-width: 100% !important;
      margin-bottom: 15px !important;
  }

  #ielts-instruction-toggle {
      display: flex !important;
      width: 100% !important;
      margin-top: 10px !important;
      height: auto !important;
      min-height: 44px;
      padding: 8px 15px;
      justify-content: center !important;
      background: #ffffff;
      font-size: 13px !important;
      border: 1.5px solid #e5e7eb;
      border-radius: 8px !important; /* Force rounded corners */
  }

  .ielts-instruction-box { 
      padding: 15px !important; 
      width: 100% !important; 
      box-sizing: border-box !important; 
  }
  
  .ielts-instruction-box h3 { font-size: 16px !important; }
  .ielts-instruction-box li { font-size: 14px !important; line-height: 1.5 !important; }
}

/* ==========================================================================
   FINAL IELTS PRO TYPOGRAPHY FIX (WRITING MODULE MODE)
   ========================================================================== */

/* 1. NUCLEAR BOLDNESS ONLY
   This uses the body selector prefix and !important to force the browser 
   to respect the bold tags (b and strong) exactly as seen in the editor.
*/
body .writing-mode b, 
body .writing-mode strong,
body .writing-mode .ielts-task-prompt b,
body .writing-mode .ielts-task-prompt strong,
body .writing-mode .ielts-review-content b,
body .writing-mode .ielts-review-content strong {
    font-weight: 800 !important;
    display: inline !important;
    color: inherit !important;
}

/* Ensure inline spans with bold font-weight are also captured */
body .writing-mode span[style*="font-weight: bold"],
body .writing-mode span[style*="font-weight:bold"],
body .writing-mode span[style*="font-weight: 700"],
body .writing-mode span[style*="font-weight:700"],
body .writing-mode span[style*="font-weight: 800"],
body .writing-mode span[style*="font-weight:800"] {
    font-weight: 800 !important;
}

body .writing-mode .ielts-task-prompt b,
body .writing-mode .ielts-task-prompt strong {
    font-weight: 700 !important;
}

body .writing-mode .ielts-task-prompt span[style*="font-weight: bold"],
body .writing-mode .ielts-task-prompt span[style*="font-weight:bold"],
body .writing-mode .ielts-task-prompt span[style*="font-weight: 700"],
body .writing-mode .ielts-task-prompt span[style*="font-weight:700"],
body .writing-mode .ielts-task-prompt span[style*="font-weight: 800"],
body .writing-mode .ielts-task-prompt span[style*="font-weight:800"] {
    font-weight: 700 !important;
}

@media (max-width: 1024px) {
    .ielts-prestart-layout {
        grid-template-columns: 1fr;
        gap: 32px;
        max-width: 100%;
        padding: 16px 16px 20px;
    }

    body.ielts-standalone-mode .ielts-prestart-layout,
    body.ielts-standalone-preview .ielts-prestart-layout {
        min-height: 0;
        align-content: start;
    }

    .ielts-prestart-right {
        max-width: 100%;
        justify-self: stretch;
    }

    .ielts-candidate-card {
        position: static;
        top: auto;
        max-width: 100%;
    }

    .ielts-top-bar {
        height: auto;
        min-height: 48px;
        padding: 8px 12px;
        gap: 12px;
        flex-wrap: wrap;
    }

    .ielts-top-bar-left,
    .ielts-top-bar-right {
        min-width: 0;
    }

    .ielts-top-bar-title {
        font-size: 16px;
    }

    .ielts-top-bar-right {
        gap: 8px;
        flex-wrap: wrap;
    }

    .ielts-header-controls {
        gap: 8px;
        padding: 0 12px;
    }

    .ielts-pagination-footer {
        height: 68px;
        padding: 0 12px;
    }

    .parts-grid {
        height: 48px;
        gap: 6px;
    }
}

@media (max-width: 640px) {
    .ielts-prestart-layout {
        gap: 18px;
        padding: 10px 0 14px;
    }

    .ielts-prestart-layout--mock .ielts-prestart-left {
        padding: 24px 18px 26px;
    }

    .ielts-candidate-card {
        padding: 20px 18px;
    }

    .ielts-pagination-footer {
        height: 50px;
        padding: 0 10px;
    }

    .parts-grid {
        height: 44px;
        gap: 5px;
    }

    .ielts-notes-sidebar {
        width: 86vw;
        right: -86vw;
        max-width: 320px;
    }

    .ielts-final-wrapper .ielts-writing-dragger {
        width: 100% !important;
        height: 20px !important;
        flex-basis: 20px !important;
        cursor: row-resize !important;
        border-left: none !important;
        border-right: none !important;
        border-top: 1px solid #e5e7eb;
        border-bottom: 1px solid #e5e7eb;
    }

    .ielts-final-wrapper .ielts-writing-dragger::before {
        transform: rotate(90deg);
    }
}

@media (max-width: 480px) {
    .ielts-prestart-layout {
        gap: 14px;
        padding: 8px 0 12px;
    }

    .ielts-prestart-layout--mock .ielts-prestart-left {
        padding: 20px 12px 22px;
    }

    .ielts-prestart-layout--mock .ielts-top-bar {
        height: 38px !important;
        min-height: 38px !important;
        padding: 0 6px !important;
        gap: 3px !important;
        flex-wrap: nowrap !important;
    }

    .ielts-prestart-layout--mock .ielts-top-bar-title {
        font-size: 12px;
        max-width: 120px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ielts-prestart-layout--mock .ielts-top-bar-right,
    .ielts-prestart-layout--mock .ielts-header-controls {
        gap: 4px !important;
    }

    .ielts-prestart-layout--mock .ielts-header-controls {
        padding: 0 6px;
    }

    .ielts-prestart-layout--mock .ielts-pagination-footer {
        height: 46px;
        padding: 0 4px;
    }

    .ielts-prestart-layout--mock .parts-grid {
        height: 40px;
        gap: 2px;
    }

    .ielts-prestart-layout--mock .ielts-notes-sidebar {
        width: 100vw;
        right: -100vw;
        max-width: none;
    }

    .ielts-candidate-card {
        padding: 16px 12px;
    }

    .ielts-pagination-footer {
        padding: 0 6px;
    }

    .parts-grid {
        gap: 3px;
    }

    .ielts-writing-prompt {
        padding: 12px;
    }

    .ielts-task-header-row {
        gap: 6px;
    }
}

/* Mobile overflow containment for writing runtime footer. */
@media (max-width: 768px) {
    .ielts-final-wrapper.writing-mode.test-started .ielts-pagination-footer {
        box-sizing: border-box !important;
        width: 100vw !important;
        max-width: 100vw !important;
        padding-left: 6px !important;
        padding-right: 6px !important;
        overflow: hidden !important;
    }

    .ielts-final-wrapper.writing-mode.test-started .parts-grid,
    .ielts-final-wrapper.writing-mode.test-started .part-box,
    .ielts-final-wrapper.writing-mode.test-started .box-questions-area,
    .ielts-final-wrapper.writing-mode.test-started .box-summary-text {
        box-sizing: border-box !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .ielts-final-wrapper.writing-mode.test-started .part-box {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}
