:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;

    --color-primary: #3b82f6;
    /* Blue */
    --color-primary-light: #1e3a8a;
    --color-primary-hover: #2563eb;

    --color-accent: #f59e0b;
    /* Optional warm accent for warnings/reset */

    --color-correct: #22c55e;
    --color-correct-bg: #14532d;
    --color-wrong: #ef4444;
    --color-wrong-bg: #7f1d1d;

    --font-family: 'Inter', sans-serif;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
}

[v-cloak] {
    display: none;
}

/* Utilities */
.text-primary {
    color: var(--color-primary);
}

.text-green {
    color: var(--color-correct);
}

.text-red {
    color: var(--color-wrong);
}

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

.bg-primary {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
}

.bg-accent {
    background-color: rgba(245, 158, 11, 0.2);
    color: var(--color-accent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: 14px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
}

.btn-primary:hover:not(:disabled),
.btn-primary:active:not(:disabled) {
    background-color: var(--color-primary-hover);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover:not(:disabled) {
    background-color: #334155;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
}

.btn-text:hover {
    color: var(--text-main);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}

.modal-content {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.modal-lg {
    max-width: 720px;
    width: 100%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-content input[type="text"] {
    width: 100%;
    padding: 12px;
    margin: 16px 0;
    border: 1px solid var(--border-color);
    background: #0f172a;
    color: var(--text-main);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
}

.modal-content form button {
    width: 100%;
}

/* Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Navigation Bar */
.top-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 500;
    height: 52px;
    gap: 12px;
    min-width: 0;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.nav-left .nav-home-btn {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    padding: 6px 14px;
    border-radius: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1;
}

.nav-left .nav-home-btn.active,
.nav-left .nav-home-btn:hover {
    color: var(--color-primary);
    background: var(--color-primary-light);
}

.nav-right {
    position: relative;
    flex-shrink: 0;
    margin-left: auto;
}

.user-account-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 10px;
    transition: background 0.2s ease;
    user-select: none;
    white-space: nowrap;
}

.user-account-menu:hover {
    background: #0f172a;
}

.avatar {
    width: 30px;
    height: 30px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
}

.username-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cloud-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    flex-shrink: 0;
}

.cloud-dot.online {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

.menu-arrow {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* User Dropdown Popover */
.user-dropdown-popover {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 180px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    padding: 8px;
    z-index: 1000;
}

.dropdown-user-info {
    padding: 6px 8px;
}

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

.popover-status {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.dropdown-divider {
    height: 1px;
    background: #334155;
    margin: 6px 0;
}

.dropdown-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: transparent;
    border: none;
    color: #ef4444;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.dropdown-logout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
}

.main-content {
    flex: 1;
    padding: 12px 16px;
    overflow-y: auto;
}

.header h1 {
    font-size: 20px;
    margin-bottom: 16px;
}

/* Dashboard Progress */
.progress-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 40px;
}

.progress-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.progress-card .icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.progress-card .info {
    flex: 1;
}

.progress-card .info h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.bar-container {
    width: 100%;
    height: 8px;
    background: #0f172a;
    border-radius: 4px;
    overflow: hidden;
}

.bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-card .stats {
    text-align: right;
    min-width: 120px;
}

.progress-card .stats span {
    display: block;
}

.progress-card .stats span:last-child {
    font-weight: bold;
    font-size: 18px;
}

/* Tests Section */
.tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1px;
}

.tabs button {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tabs button.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.test-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
}

.test-card h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

.test-meta {
    display: flex;
    gap: 16px;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 16px;
}

.test-status {
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.last-time-badge {
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 500;
}

.test-actions {
    display: flex;
    gap: 12px;
}

.test-actions button {
    flex: 1;
}

/* Setup Modal */
.mode-tabs {
    display: flex;
    background: #0f172a;
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 24px;
}

.mode-tabs button {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
}

.mode-tabs button.active {
    background: #334155;
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
    font-size: 14px;
}

.alert-info {
    background: var(--color-primary-light);
    color: #7dd3fc;
}

.part-selector {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    overflow: hidden;
}

.part-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #334155;
    background: #1e293b;
    gap: 16px;
    flex-wrap: wrap;
}

.part-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.select-all-box {
    position: relative;
    padding-left: 32px;
    margin-bottom: 0;
}

.select-all-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-main);
}

.total-q-badge {
    background: #334155;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.start-practice-btn {
    padding: 8px 20px;
    font-weight: 600;
}

.parts-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.section-title {
    grid-column: 1 / -1;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #94a3b8;
    text-transform: uppercase;
    margin-top: 8px;
    margin-bottom: 4px;
}

.part-item {
    display: flex;
    align-items: center;
    position: relative;
    padding: 14px 16px 14px 44px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.part-item:hover {
    border-color: var(--color-primary);
    background: #334155;
}

.part-item.is-selected {
    border-color: var(--color-primary);
    background: rgba(56, 189, 248, 0.08);
}

.part-item .part-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-main);
}

.part-item .q-count {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 13px;
}

.part-item .q-count.q-done {
    color: var(--color-primary);
    font-weight: 600;
}

.part-item .q-count.q-complete {
    color: #22c55e;
}

.part-item .q-count.q-complete::after {
    content: ' ✓';
}

/* Custom Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    cursor: pointer;
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    height: 20px;
    width: 20px;
    background-color: #0f172a;
    border: 2px solid #475569;
    border-radius: 5px;
    transition: all 0.2s ease;
}

.select-all-box .checkmark {
    left: 0;
}

.checkbox-container:hover input~.checkmark {
    border-color: var(--color-primary);
}

.checkbox-container input:checked~.checkmark {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked~.checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 50%;
    top: 45%;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2.5px 2.5px 0;
    transform: translate(-50%, -50%) rotate(45deg);
}

/* Practice Interface */
.practice-view {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    z-index: 800;
    padding: 8px 12px 0 12px;
}

.practice-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.practice-header h2 {
    font-size: 16px;
    margin: 0;
    flex: 1;
}

.progress-text {
    font-weight: 600;
    color: var(--text-muted);
}

.practice-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.question-container {
    display: flex;
    gap: 0;
    flex: 1;
    min-height: 0;
}

.context-panel {
    flex: 1;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 200px;
}

/* ── Panel Resizer ── */
.panel-resizer {
    width: 8px;
    margin: 0 2px;
    flex-shrink: 0;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: col-resize;
    position: relative;
    z-index: 10;
    touch-action: none;
    transition: background 0.15s ease;
}

.panel-resizer:hover,
.panel-resizer:active {
    background: rgba(99, 102, 241, 0.08);
    border-radius: 4px;
}

.resizer-handle {
    width: 4px;
    height: 48px;
    background: var(--border-color);
    border-radius: 999px;
    transition: all 0.2s ease;
    pointer-events: none;
}

.panel-resizer:hover .resizer-handle,
.panel-resizer:active .resizer-handle {
    height: 64px;
    background: var(--color-primary);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
    width: 4px;
}

/* Dots decoration on handle */
.resizer-handle::before,
.resizer-handle::after {
    content: '';
    display: block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.2s ease;
    position: absolute;
}

.panel-resizer:hover .resizer-handle::before,
.panel-resizer:hover .resizer-handle::after {
    opacity: 0.5;
}

.question-panel {
    flex: 1;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.question-panel.full-width {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}


.audio-player {
    background: rgba(0, 0, 0, 0.15);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

.audio-player audio {
    width: 100%;
    margin-bottom: 0;
    display: block;
}

.custom-audio-ui {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    margin-bottom: 4px;
}

.audio-play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.audio-play-btn:hover {
    background: var(--color-primary);
    transform: scale(1.05);
}

.audio-progress-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.audio-time {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    min-width: 36px;
    text-align: center;
}

.audio-seek-bar {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.audio-seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    transition: all 0.1s;
}

.audio-seek-bar::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--color-primary);
}

.audio-seek-bar::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: none;
}

.audio-controls {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-top: 6px;
}

.audio-controls button,
.audio-controls select {
    width: 100%;
    height: 34px;
    border: 1px solid var(--border-color);
    background: #1e293b;
    color: var(--text-main);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
    white-space: nowrap;
}

.audio-controls button:hover,
.audio-controls select:hover {
    background: #334155;
    border-color: var(--color-primary);
}

.audio-controls select {
    text-align-last: center;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 4px center;
    background-size: 12px;
    padding-right: 16px;
}

.passage-image img {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 24px;
}

.reading-passage-box {
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 8px;
}

/* Chat & Passage Light-Background Text Contrast Fix */
.passage-text [style*="background"],
.passage-text [style*="background-color"] {
    color: #0f172a !important;
}

.passage-text [style*="background"] *,
.passage-text [style*="background-color"] * {
    color: #0f172a !important;
}

.passage-text .textmsg,
.passage-text .chat {
    background: #0f172a !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px;
    padding: 16px !important;
    max-width: 100% !important;
}

.passage-text .textmsg>div,
.passage-text .chat>div {
    border-radius: 12px !important;
    padding: 10px 14px !important;
    margin-bottom: 10px !important;
    font-size: 14.5px;
    line-height: 1.5;
    color: #0f172a !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.passage-text .textmsg>div *,
.passage-text .chat>div * {
    color: #0f172a !important;
}

.passage-text .textmsg b,
.passage-text .textmsg strong,
.passage-text .chat b,
.passage-text .chat strong {
    color: #0f172a !important;
    font-weight: 700 !important;
}

.passage-text .webpage,
.passage-text .email,
.passage-text .article,
.passage-text .letter,
.passage-text .notice,
.passage-text .report,
.passage-text .jobad {
    background: #0f172a !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px;
    padding: 16px !important;
    color: var(--text-main);
}

/* iOS Style Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

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

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Toggle Card */
.toggle-card {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    margin-top: 10px;
    overflow: hidden;
}

.toggle-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: transparent;
    cursor: pointer;
    user-select: none;
}

.toggle-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text-main);
}

.toggle-card-body {
    padding: 10px 14px;
    font-size: 13.5px;
    line-height: 1.5;
    border-top: 1px dashed rgba(255, 255, 255, 0.05);
}

/* Group Badge */
.group-header-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.badge-tag {
    background: #334155;
    color: var(--text-main);
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
}

.badge-sub {
    color: var(--text-muted);
    font-size: 13px;
}

/* Tag Badges for Explanation */
.tag-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    margin-right: 6px;
}

.tag-script {
    background: #0c4a6e;
    color: #38bdf8;
}

.tag-paraphrase {
    background: #14532d;
    color: #4ade80;
}

.question-card-item {
    background: rgba(0, 0, 0, 0.15);
    border: none;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
}

.question-card-item h3 {
    font-size: 14.5px;
    margin-bottom: 8px;
    color: var(--text-main);
}

.q-text {
    font-size: 14.5px;
    margin-bottom: 10px;
    font-weight: 500;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.option-item {
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.2s ease;
}

.option-item:hover:not(.correct-option):not(.wrong-option) {
    background: rgba(255, 255, 255, 0.08);
}

/* Custom Radio */
.radio-container {
    display: flex;
    align-items: flex-start;
    position: relative;
    padding-left: 32px;
    cursor: pointer;
    user-select: none;
}

.radio-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.radiomark {
    position: absolute;
    top: 10px;
    left: 10px;
    height: 18px;
    width: 18px;
    background-color: #0f172a;
    border: 2px solid var(--border-color);
    border-radius: 50%;
}

.radio-container:hover input~.radiomark {
    border-color: var(--color-primary);
}

.radio-container input:checked~.radiomark {
    border-color: var(--color-primary);
}

.radiomark:after {
    content: "";
    position: absolute;
    display: none;
}

.radio-container input:checked~.radiomark:after {
    display: block;
}

.radio-container .radiomark:after {
    top: 4px;
    left: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-primary);
}

.opt-label {
    margin-right: 8px;
    font-weight: 600;
}

/* Answer feedback styling */
.correct-option {
    border-color: transparent;
    background-color: var(--color-correct-bg);
}

.correct-option .radiomark {
    border-color: var(--color-correct);
}

.correct-option .radiomark:after {
    background: var(--color-correct);
}

.wrong-option {
    border-color: transparent;
    background-color: var(--color-wrong-bg);
}

.wrong-option .radiomark {
    border-color: var(--color-wrong);
}

.wrong-option .radiomark:after {
    background: var(--color-wrong);
}

.explanation-box {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.explanation-box h4 {
    margin-bottom: 16px;
}

.explanation-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.btn-tab {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: #0f172a;
    color: var(--text-muted);
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
}

.btn-tab.active {
    background: var(--color-primary);
    color: #0f172a;
    border-color: var(--color-primary);
    font-weight: 600;
}

.explanation-content {
    background: #0f172a;
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.6;
}

.exp-html {
    margin-bottom: 12px;
}

.navigation-controls {
    flex-shrink: 0;
    z-index: 500;
    background: #1e293b;
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.navigation-controls button {
    flex: 1;
}

.reset-group-btn {
    background: #0f172a;
    color: #f59e0b;
    border: 1px solid #f59e0b;
    transition: all 0.2s ease;
    font-weight: 600;
}

.reset-group-btn:hover {
    background: #f59e0b;
    color: #0f172a;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 18px;
    color: var(--text-muted);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 12px;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.username-text {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-main);
}

.cloud-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #94a3b8;
}

.cloud-status.online {
    color: var(--color-correct);
}

.cloud-status .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #94a3b8;
}

.cloud-status.online .dot {
    background-color: var(--color-correct);
    box-shadow: 0 0 6px rgba(22, 163, 74, 0.6);
}

/* Transcript Toggle */
.transcript-wrapper {
    margin-top: 16px;
}

.transcript-toggle-box {
    margin-bottom: 12px;
}

.transcript-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--color-primary);
    border-color: var(--color-primary-light);
    background-color: var(--color-primary-light);
    padding: 8px 14px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.transcript-btn:hover {
    background-color: #dbeafe;
}

/* Tests Section & Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
}

.tabs::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

.tabs button {
    background: none;
    border: none;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    flex-shrink: 0;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .question-container {
        flex-direction: column;
        gap: 8px;
    }

    .context-panel {
        max-height: 45vh;
        width: 100% !important; /* override inline resizer style */
    }

    .question-panel {
        width: 100% !important;
    }

    /* Ẩn resizer dọc, hiển thị dạng separator ngang */
    .panel-resizer {
        width: 100%;
        height: 8px;
        margin: 2px 0;
        cursor: row-resize;
        align-items: center;
        justify-content: center;
    }

    .resizer-handle {
        width: 48px;
        height: 4px;
    }

    .panel-resizer:hover .resizer-handle,
    .panel-resizer:active .resizer-handle {
        width: 64px;
        height: 4px;
    }
}

@media (max-width: 768px) {
    .top-nav-bar {
        padding: 0 12px;
        height: 48px;
    }

    .nav-left {
        gap: 2px;
    }

    .nav-left .nav-home-btn {
        padding: 5px 10px;
        font-size: 13px;
    }

    .username-text {
        max-width: 80px;
    }

    .main-content {
        padding: 12px;
    }

    .header h1 {
        font-size: 20px;
        margin-bottom: 20px;
    }

    .tests-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 16px;
    }

    .parts-grid {
        grid-template-columns: 1fr;
    }

    .practice-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .practice-header h2 {
        font-size: 15px;
        width: 100%;
        order: 3;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 12px;
    }

    .progress-card {
        padding: 14px;
        gap: 14px;
    }

    .progress-card .icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .progress-card .stats {
        min-width: 90px;
        font-size: 13px;
    }

    .test-card {
        padding: 16px;
    }

    .test-actions {
        display: flex;
        flex-direction: row;
        gap: 8px;
    }

    .modal-content {
        padding: 20px 16px;
        width: 95%;
    }

    .modal-lg {
        padding: 16px;
    }

    .navigation-controls {
        gap: 10px;
    }

    .navigation-controls button {
        flex: 1;
        padding: 10px 8px;
        font-size: 13px;
    }

    .option-item {
        padding: 12px 14px;
        font-size: 14px;
    }

    .radio-container {
        padding-left: 36px;
    }

    .radiomark {
        top: 14px;
        left: 12px;
    }
}


/* Quick Actions (Homepage CTA) */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.action-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.3s ease;
    cursor: pointer;
}

.action-card:hover {
    border-color: var(--color-primary);
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.08), rgba(249, 115, 22, 0.02));
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(249, 115, 22, 0.15);
}

.action-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--color-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}

.action-info {
    flex: 1;
}

.action-info h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.action-info p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

.action-arrow {
    font-size: 24px;
    color: var(--text-muted);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.action-card:hover .action-arrow {
    color: var(--color-primary);
    transform: translateX(4px);
}

/* Nav Left multi-link */
.nav-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Tests Progress Summary */
.tests-progress-summary {
    margin-bottom: 24px;
}

/* ==========================================================================
   DIFFICULTY PRACTICE SCREEN STYLES (Light & Clean Design)
   ========================================================================== */

.difficulty-body {
    background-color: #f8fafc;
    color: #1e293b;
}

.difficulty-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* Top Tabs */
.difficulty-top-tabs {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.top-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 9999px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    background-color: #e2e8f0;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.top-tab-btn:hover {
    background-color: #cbd5e1;
}

.top-tab-btn.active {
    background-color: #059669;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

/* Part Pills */
.difficulty-part-pills {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.part-pill-btn {
    padding: 8px 18px;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid #cbd5e1;
    background-color: #ffffff;
    color: #334155;
    cursor: pointer;
    transition: all 0.2s ease;
}

.part-pill-btn:hover {
    background-color: #f1f5f9;
}

.part-pill-btn.active {
    background-color: #059669;
    color: #ffffff;
    border-color: #059669;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.2);
}

/* Difficulty Cards Grid */
.difficulty-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
}

.difficulty-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.25s ease;
}

.difficulty-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.07);
}

.difficulty-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 6px;
    border-top-left-radius: 16px;
    border-bottom-left-radius: 16px;
}

.difficulty-card.level-card-1::before {
    background-color: #10b981;
}

.difficulty-card.level-card-2::before {
    background-color: #3b82f6;
}

.difficulty-card.level-card-3::before {
    background-color: #f59e0b;
}

.difficulty-card.level-card-4::before {
    background-color: #f97316;
}

.difficulty-card.level-card-5::before {
    background-color: #ef4444;
}

/* Card Header Row */
.card-header-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.icon-badge {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.title-meta {
    flex: 1;
}

.level-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 2px;
}

.error-rate-text {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

/* Card Progress Section */
.card-progress-section {
    margin-bottom: 20px;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
}

.card-progress-bar-bg {
    width: 100%;
    height: 8px;
    background-color: #f1f5f9;
    border-radius: 9999px;
    overflow: hidden;
}

.card-progress-bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.4s ease;
}

/* Stats Pills Row */
.stats-pills-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.stat-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
}

.stat-correct {
    background-color: #e6f4ea;
    color: #137333;
}

.stat-wrong {
    background-color: #fce8e6;
    color: #c5221f;
}

.stat-unanswered {
    background-color: #f1f5f9;
    color: #475569;
}

/* Card Action Row */
.card-actions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.quick-icons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s ease;
}

.icon-action-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.icon-action-btn.btn-trash {
    color: #ef4444;
    background: #fef2f2;
    border-color: #fee2e2;
}

.icon-action-btn.btn-trash:hover {
    background: #fee2e2;
    color: #dc2626;
}

.btn-practice-now {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    background-color: #059669;
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.2);
}

.btn-practice-now:hover {
    background-color: #047857;
    box-shadow: 0 6px 16px rgba(5, 150, 105, 0.3);
}

/* Practice Mode UI */
.practice-container {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.practice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.practice-title-info h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
}

.practice-subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

.practice-header-right {
    display: flex;
    gap: 12px;
}

.score-badge {
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 700;
}

.score-badge.correct-bg {
    background-color: var(--color-correct-bg);
    color: var(--color-correct);
}

.score-badge.wrong-bg {
    background-color: var(--color-wrong-bg);
    color: var(--color-wrong);
}

.passage-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 16px;
}

.passage-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-main);
}

.exp-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-main);
}

.q-nav-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}
/* Level Badges for Tests */
.badge-level {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.level-1 { background-color: #27ae60; }
.level-2 { background-color: #2980b9; }
.level-3 { background-color: #f39c12; }
.level-4 { background-color: #d35400; }
.level-5 { background-color: #c0392b; }
