/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* Top purple banner */
.top-banner {
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.home-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.15rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.home-btn:hover {
    background-color: rgba(255, 255, 255, 0.35);
    transform: scale(1.05);
}

.logo {
    height: 50px;
    width: auto;
    object-fit: contain;
    pointer-events: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.login-btn {
    background-color: white;
    color: #7c3aed;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    background-color: #f9fafb;
}

/* Language Switcher */
.lang-switcher {
    position: relative;
}

.lang-switcher-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: white;
    color: #7c3aed;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 25px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.lang-switcher-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    background-color: #f9fafb;
}

.lang-flag {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.lang-arrow {
    font-size: 0.65rem;
    transition: transform 0.3s ease;
    margin-left: 0.15rem;
}

.lang-switcher.open .lang-arrow {
    transform: rotate(180deg);
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 200;
    min-width: 160px;
}

.lang-switcher.open .lang-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-weight: 500;
    color: #333;
    font-size: 0.95rem;
}

.lang-option:hover {
    background-color: #ede9fe;
    color: #7c3aed;
}

.lang-option.active {
    background-color: #f3e8ff;
    color: #7c3aed;
    font-weight: 600;
}

/* Main container */
.main-container {
    display: flex;
    min-height: calc(100vh - 82px);
    gap: 1.5rem;
    padding: 2rem;
}

/* Content Area */
.content-area {
    flex: 1;
    display: flex;
    gap: 1.5rem;
}

/* View Container */
.view-container {
    display: none;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
    width: 100%;
}

.view-container.active {
    display: flex;
}

#home-view {
    width: 100%;
}

#home-view.active {
    gap: 1.5rem;
    flex-direction: row;
}

#home-view .learning-modes-section {
    width: 62.5%;
    flex-shrink: 0;
}

#home-view .dashboard-section {
    width: 37.5%;
    flex-shrink: 0;
}

.view-container.full-width {
    width: 100%;
    flex-direction: column;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Section titles */
.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid #7c3aed;
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Back button */
.back-btn {
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
    color: white;
    border: none;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.back-btn:hover {
    transform: translateX(-3px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.back-btn i {
    font-size: 1.2rem;
}

/* Menu Section (20%) */
.menu-section {
    width: 20%;
    background-color: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    height: fit-content;
    position: sticky;
    top: 100px;
}

.menu-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background-color: #f9fafb;
    border-radius: 10px;
    text-decoration: none;
    color: #4b5563;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.menu-item:hover {
    background-color: #ede9fe;
    color: #7c3aed;
    border-color: #7c3aed;
    transform: translateX(5px);
}

.menu-item i {
    font-size: 1.25rem;
    width: 25px;
    text-align: center;
}

/* Learning Modes Section */
.learning-modes-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.mode-card {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    transition: all 0.3s ease;
    cursor: pointer;
    gap: 2rem;
}

.mode-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(124, 58, 237, 0.15);
    border: 2px solid #7c3aed;
}

.mode-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mode-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.mode-description {
    font-size: 1rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.mode-image {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ede9fe 0%, #f3e8ff 100%);
    border-radius: 15px;
    padding: 1rem;
}

.mode-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Dashboard Section */
.dashboard-section {
    background-color: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    height: fit-content;
    position: sticky;
    top: 100px;
}

.dashboard-content {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-style: italic;
}

/* My Courses View */
.courses-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.course-category {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
}

.category-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.category-title i {
    color: #7c3aed;
}

.category-content {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.level-image {
    width: 150px;
    height: 150px;
    object-fit: contain;
    background: linear-gradient(135deg, #ede9fe 0%, #f3e8ff 100%);
    border-radius: 15px;
    padding: 1rem;
    flex-shrink: 0;
}

.course-tags {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}

.course-tag {
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 1rem 1.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.course-tag:hover {
    background: #ede9fe;
    border-color: #7c3aed;
    color: #7c3aed;
    transform: translateX(10px);
}

/* Course Detail View */
.course-detail {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
}

.units-scroll-container {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding-right: 0.5rem;
}

.units-scroll-container::-webkit-scrollbar {
    width: 10px;
}

.units-scroll-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.units-scroll-container::-webkit-scrollbar-thumb {
    background: #7c3aed;
    border-radius: 10px;
}

.units-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #6d28d9;
}

.units-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.unit-card {
    background: #f9fafb;
    border-radius: 12px;
    padding: 1.5rem;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
}

.unit-card:hover {
    border-color: #c4b5fd;
}

.unit-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 1rem;
}

.unit-topic {
    background: white;
    border: 2px solid #7c3aed;
    border-radius: 10px;
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: #7c3aed;
    cursor: pointer;
    transition: all 0.3s ease;
    width: fit-content;
    display: block;
}

.unit-topic:hover {
    background: #7c3aed;
    color: white;
    transform: translateX(5px);
}

.unit-topic.expanded {
    background: #7c3aed;
    color: white;
}

.unit-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    margin-top: 0;
}

.unit-content.expanded {
    max-height: 2000px;
    margin-top: 1.5rem;
}

/* Compact Mode Cards for Units */
.mode-card.compact {
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.mode-card.compact:last-child {
    margin-bottom: 0;
}

.mode-card.compact .mode-title {
    font-size: 1.25rem;
}

.mode-card.compact .mode-description {
    font-size: 0.95rem;
}

.mode-card.compact .mode-image {
    width: 100px;
    height: 100px;
}

/* Unit Detail View (Roleplay View) */
.unit-detail {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
}

.roleplays-container {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.roleplay-card {
    background: #f9fafb;
    border-radius: 15px;
    padding: 2rem;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
}

.roleplay-card:hover {
    border-color: #c4b5fd;
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.1);
}

.roleplay-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 1.5rem;
}

.roleplay-content {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.roleplay-image-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-shrink: 0;
}

.roleplay-image {
    width: 280px;
    height: auto;
    border-radius: 15px;
    object-fit: cover;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.start-btn {
    width: 280px;
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(124, 58, 237, 0.3);
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(124, 58, 237, 0.4);
}

.roleplay-description {
    flex: 1;
    background: white;
    border-radius: 12px;
    padding: 1.75rem;
    border: 2px solid #e5e7eb;
}

.description-item {
    margin-bottom: 1.5rem;
}

.description-item:last-child {
    margin-bottom: 0;
}

.description-label {
    font-weight: 700;
    font-style: italic;
    color: #7c3aed;
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.description-label i {
    font-size: 1rem;
    width: 20px;
}

.description-text {
    color: #4b5563;
    line-height: 1.6;
    font-size: 0.98rem;
}

/* ===== Chat View ===== */
#chat-view.active {
    gap: 1.5rem;
    flex-direction: row;
}

.chat-section {
    width: 62.5%;
    flex-shrink: 0;
}

.chat-info-section {
    width: 37.5%;
    flex-shrink: 0;
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    height: calc(100vh - 130px);
    position: sticky;
    top: 100px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-side-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.chat-side-rule {
    border-bottom: 3px solid #7c3aed;
    margin-bottom: 0.75rem;
}

.chat-feedback-back-row {
    display: none;
    justify-content: flex-start;
    margin: 0 0 0.85rem;
}

.chat-feedback-back-row.show {
    display: flex;
}

.chat-feedback-back-btn {
    width: 36px;
    height: 36px;
}

.chat-side-tab {
    border: none;
    border-radius: 999px;
    padding: 0.65rem 0.5rem;
    background: #ede9fe;
    color: #6d28d9;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-side-tab:hover,
.chat-side-tab.active {
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
    color: white;
    box-shadow: 0 6px 14px rgba(124, 58, 237, 0.18);
}

.chat-side-panel {
    display: none;
}

.chat-side-panel.active {
    display: block;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.feedback-panel.active {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-info-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.info-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.vocabulary-content {
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    padding-right: 0.35rem;
}

.vocabulary-section {
    margin-bottom: 1.25rem;
}

.vocabulary-section h3 {
    color: #1f2937;
    font-size: 1.05rem;
    margin-bottom: 0.55rem;
}

.vocabulary-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.vocabulary-chip {
    background: #f5f3ff;
    color: #4c1d95;
    border: 1px solid #ddd6fe;
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    font-size: 0.86rem;
    line-height: 1.35;
}

.feedback-panel {
    position: relative;
    flex: 1;
    min-height: 0;
}

.feedback-start {
    min-height: 320px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-align: center;
    color: #6b7280;
}

.feedback-robot-img {
    width: 86px;
    height: 86px;
    border-radius: 50%;
    object-fit: cover;
    background: #ede9fe;
    border: 3px solid #ddd6fe;
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.14);
}

.feedback-action-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.feedback-btn {
    border: none;
    border-radius: 999px;
    padding: 0.75rem 1.6rem;
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    width: min(100%, 22rem);
    line-height: 1.3;
}

.feedback-btn-compact {
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
}

.feedback-btn-detailed {
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
}

.feedback-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(124, 58, 237, 0.24);
}

.feedback-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.compact-feedback h3 {
    color: #6d28d9;
    font-size: 1.05rem;
    margin: 0 0 0.65rem;
}

.compact-feedback h3:not(:first-child) {
    margin-top: 1.15rem;
}

.compact-went-well {
    list-style: none;
    padding: 0;
    margin: 0;
}

.compact-went-well li {
    color: #4b5563;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 0.45rem;
}

.compact-improvements {
    margin: 0;
    padding-left: 1.2rem;
    color: #4b5563;
}

.compact-improvements li {
    margin-bottom: 0.9rem;
}

.compact-improve-label {
    font-weight: 700;
    color: #374151;
    margin-bottom: 0.35rem;
}

.compact-improvements p {
    margin: 0.2rem 0;
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.feedback-loading {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    background: rgba(255, 255, 255, 0.76);
    color: #6d28d9;
    font-weight: 700;
    border-radius: 12px;
    z-index: 5;
}

.feedback-loading.open {
    display: flex;
}

.feedback-spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 4px solid #ddd6fe;
    border-top-color: #7c3aed;
    animation: feedbackSpin 0.9s linear infinite;
}

@keyframes feedbackSpin {
    to {
        transform: rotate(360deg);
    }
}

.feedback-result {
    display: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.35rem;
    color: #1f2937;
}

.feedback-result.show {
    display: block;
}

.feedback-round {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #f9fafb;
}

.feedback-round h3 {
    color: #6d28d9;
    font-size: 1rem;
    margin-bottom: 0.65rem;
}

.feedback-field {
    margin-top: 0.65rem;
}

.feedback-field strong {
    display: block;
    color: #374151;
    margin-bottom: 0.25rem;
}

.feedback-field p {
    color: #4b5563;
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.chat-error-modal,
.feedback-error-modal {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(31, 41, 55, 0.35);
    z-index: 30;
}

.chat-error-modal.open,
.feedback-error-modal.open {
    display: flex;
}

.chat-error-dialog,
.feedback-error-dialog {
    width: min(420px, 100%);
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 20px 45px rgba(31, 41, 55, 0.25);
    text-align: center;
    animation: msgFadeIn 0.2s ease;
}

.chat-error-dialog h3,
.feedback-error-dialog h3 {
    color: #b91c1c;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.chat-error-dialog p,
.feedback-error-dialog p {
    color: #374151;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.25rem;
    white-space: pre-wrap;
}

.chat-error-dialog button,
.feedback-error-dialog button {
    border: none;
    border-radius: 999px;
    padding: 0.65rem 1.6rem;
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-error-dialog button:hover,
.feedback-error-dialog button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(124, 58, 237, 0.18);
}

.chat-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 130px);
    overflow: hidden;
    position: relative;
}

.chat-header {
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
    color: white;
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border-radius: 15px 15px 0 0;
    flex-shrink: 0;
}

.chat-back-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
}

.chat-back-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateX(-2px);
    box-shadow: none;
}

.chat-back-btn i {
    font-size: 1rem;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.7);
    flex-shrink: 0;
}

.chat-partner-name {
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin-left: auto;
    border-radius: 50%;
    border: none;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-reset-btn:hover {
    background-color: rgba(255, 255, 255, 0.35);
    transform: scale(1.05);
}

.chat-reset-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: #f5f7fa;
}

.chat-reset-modal {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(31, 41, 55, 0.35);
    z-index: 20;
}

.chat-reset-modal.open {
    display: flex;
}

.chat-reset-dialog {
    width: min(360px, 100%);
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 20px 45px rgba(31, 41, 55, 0.25);
    text-align: center;
    animation: msgFadeIn 0.2s ease;
}

.chat-reset-dialog h3 {
    color: #1f2937;
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}

.chat-reset-dialog p {
    color: #6b7280;
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
}

.chat-reset-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.chat-reset-actions button {
    border: none;
    border-radius: 999px;
    padding: 0.65rem 1.35rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-reset-cancel {
    background: #ede9fe;
    color: #6d28d9;
}

.chat-reset-confirm {
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
    color: white;
}

.chat-reset-actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(124, 58, 237, 0.18);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c4b5fd;
    border-radius: 6px;
}

.message {
    max-width: 75%;
    padding: 0.7rem 1rem;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 0.95rem;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: msgFadeIn 0.25s ease;
}

@keyframes msgFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    align-self: flex-start;
    background: white;
    color: #333;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.message.user {
    align-self: flex-end;
    background: #ddd6fe;
    color: #1f2937;
    border: 1px solid #c4b5fd;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 75%;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-6px);
    }
}

/* Chat input area */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    background: white;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 15px 15px;
    flex-shrink: 0;
}

#chatInput {
    flex: 1;
    border: 2px solid #e5e7eb;
    border-radius: 20px;
    padding: 0.65rem 1.15rem;
    font-size: 0.95rem;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s ease;
    overflow-y: auto;
}

#chatInput:focus {
    border-color: #7c3aed;
}

#chatSendBtn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

#chatSendBtn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

#chatSendBtn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chat-input-column {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.4rem;
}

.chat-input-shell {
    position: relative;
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
}

.chat-input-shell #chatInput {
    width: 100%;
    padding-right: 3.2rem;
}

body.voice-chat-mode #chatInput {
    background: #f8f7fc;
    cursor: default;
}

body.voice-recording #chatInput {
    border-color: #ddd6fe;
    background: #fbfaff;
}

.voice-recording-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0 0 0 0.35rem;
    color: #6d28d9;
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.voice-recording-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    animation: recordingPulse 1.3s ease-out infinite;
}

.voice-recording-dots {
    display: inline-block;
    width: 1.15em;
    text-align: left;
}

.voice-recording-dots::after {
    content: '';
    animation: recordingDots 1.2s steps(4, end) infinite;
}

@keyframes recordingPulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
    70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes recordingDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75%, 100% { content: '...'; }
}

#voiceLevelCanvas {
    position: absolute;
    left: 0.95rem;
    right: 3.2rem;
    height: 32px;
    width: auto;
    pointer-events: none;
}

.voice-mic-btn,
.voice-stop-btn {
    position: absolute;
    right: 0.35rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.voice-mic-btn[hidden],
.voice-stop-btn[hidden],
#voiceLevelCanvas[hidden],
#voiceRecordingLabel[hidden],
body:not(.voice-chat-mode) .voice-only {
    display: none !important;
}

.voice-mic-btn {
    background: #fff;
    color: #7c3aed;
    border: 2px solid transparent;
    box-shadow: 0 0 0 1px #e5e7eb;
}

.voice-mic-btn:hover:not(:disabled) {
    border-color: #7c3aed;
}

.voice-mic-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.voice-stop-btn {
    background: #7c3aed;
    border: none;
    color: white;
}

.voice-stop-square {
    width: 10px;
    height: 10px;
    background: white;
    display: block;
    border-radius: 1px;
}

body.voice-recording .menu-section,
body.voice-recording #homeBtn,
body.voice-recording .login-btn,
body.voice-recording #chatBackBtn,
body.voice-recording #chatResetBtn {
    pointer-events: none;
    opacity: 0.45;
}

.message.voice-message {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-width: min(82%, 460px);
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    white-space: normal;
}

.message.voice-message.bot {
    align-items: flex-start;
}

.message.voice-message.user {
    align-items: flex-end;
}

.voice-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
}

.voice-bubble {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: min(268px, 62vw);
    min-width: 188px;
    height: 54px;
    padding: 0 0.95rem;
    border: 1px solid #ebe6f7;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 1px 1px rgba(17, 24, 39, 0.04), 0 10px 28px rgba(91, 33, 182, 0.08);
    cursor: pointer;
    color: #4c1d95;
}

.message.user .voice-bubble {
    background: #ddd6fe;
    border-color: #c4b5fd;
}

.voice-bubble:hover:not(:disabled) {
    border-color: #a78bfa;
}

.voice-bubble:disabled {
    opacity: 1;
}

.voice-bubble:disabled:not(.is-playing) {
    opacity: 0.48;
    cursor: not-allowed;
}

.voice-bubble.is-playing {
    border-color: #c4b5fd;
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.16);
}

.voice-bars {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3px;
    height: 28px;
    flex: 1;
    min-width: 0;
    pointer-events: none;
}

.voice-bar {
    flex: 1 1 0;
    max-width: 3px;
    height: 100%;
    border-radius: 999px;
    background: #7c3aed;
    transform-origin: center center;
    transition: transform 0.28s ease;
}

.voice-bubble.is-playing .voice-bar {
    transition: none;
}

.voice-duration {
    flex-shrink: 0;
    min-width: 1.6rem;
    font-size: 0.78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    color: #6d28d9;
    pointer-events: none;
}

.message.bot .voice-duration {
    text-align: right;
}

.message.user .voice-duration {
    text-align: left;
}

.to-text-btn {
    flex-shrink: 0;
    border: 1px solid #e7e5ef;
    border-radius: 999px;
    background: #fff;
    color: #5b21b6;
    padding: 0.42rem 0.72rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
    cursor: pointer;
}

.to-text-btn:hover:not(:disabled) {
    border-color: #c4b5fd;
    background: #faf8ff;
}

.to-text-btn.is-hide {
    color: #4b5563;
    border-color: #e5e7eb;
    background: #f9fafb;
}

.to-text-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.voice-transcript {
    max-width: 100%;
    padding: 0.72rem 0.95rem;
    border-radius: 18px;
    background: #fff;
    border: 1px solid #e7e5ef;
    box-shadow: 0 8px 22px rgba(17, 24, 39, 0.06);
    color: #1f2937;
    line-height: 1.5;
    font-size: 0.92rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message.user .voice-transcript {
    background: #ddd6fe;
    border-color: #c4b5fd;
    color: #1f2937;
}

/* Chat completion modal */
.chat-complete-modal {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(31, 41, 55, 0.35);
    z-index: 25;
}

.chat-complete-modal.open {
    display: flex;
}

.chat-complete-dialog {
    width: min(400px, 100%);
    background: white;
    border-radius: 16px;
    padding: 2rem 1.5rem;
    box-shadow: 0 20px 45px rgba(31, 41, 55, 0.25);
    text-align: center;
    animation: msgFadeIn 0.2s ease;
}

.chat-complete-icon {
    font-size: 2.5rem;
    color: #f59e0b;
    margin-bottom: 1rem;
}

.chat-complete-text {
    color: #1f2937;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.chat-complete-dialog button {
    border: none;
    border-radius: 999px;
    padding: 0.7rem 2rem;
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
    color: white;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-complete-dialog button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(124, 58, 237, 0.18);
}

/* Menu tree */
.menu-tree-node {
    display: flex;
    flex-direction: column;
}

.menu-item.has-toggle {
    position: relative;
    cursor: default;
}

.menu-item.has-toggle .menu-item-text {
    flex: 1;
    cursor: pointer;
}

.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #9ca3af;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: auto;
}

.menu-toggle:hover {
    background: #f5f3ff;
    border-color: #7c3aed;
    color: #7c3aed;
}

.menu-toggle[aria-expanded="true"] {
    color: #7c3aed;
}

.menu-toggle i {
    transition: transform 0.25s ease;
}

.menu-toggle[aria-expanded="true"] i {
    transform: rotate(90deg);
}

.menu-subtree {
    overflow: hidden;
    transition: grid-template-rows 0.25s ease;
    display: grid;
    grid-template-rows: 0fr;
}

.menu-subtree > .menu-subtree-inner {
    min-height: 0;
    overflow: hidden;
}

.menu-subtree.expanded {
    grid-template-rows: 1fr;
}

.menu-sub-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.6rem;
    color: #4b5563;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: 8px;
    margin: 0.05rem 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    line-height: 1.4;
    text-decoration: none;
}

.menu-sub-item:hover {
    background-color: #f5f3ff;
    color: #7c3aed;
}

.menu-sub-item .menu-toggle {
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
}

.menu-sub-item-text {
    flex: 1;
    min-width: 0;
}

.menu-sub-level-1 {
    padding-left: 1rem;
    font-weight: 600;
    font-size: 0.86rem;
    color: #374151;
    border-left: 2px solid #ede9fe;
    margin-left: 0.75rem;
    border-radius: 0 8px 8px 0;
}

.menu-sub-level-1:hover {
    border-left-color: #7c3aed;
}

.menu-sub-level-2 {
    padding-left: 1rem;
    font-size: 0.83rem;
    border-left: 2px solid #f3e8ff;
    margin-left: 1.5rem;
    border-radius: 0 8px 8px 0;
    cursor: default;
}

.menu-sub-level-2:hover {
    border-left-color: #a78bfa;
    background-color: transparent;
    color: #4b5563;
}

.menu-sub-level-3 {
    padding-left: 1rem;
    font-size: 0.82rem;
    border-left: 2px solid #f9f5ff;
    margin-left: 2.25rem;
    border-radius: 0 8px 8px 0;
    color: #6b7280;
}

.menu-sub-level-3:hover {
    border-left-color: #c4b5fd;
    color: #7c3aed;
}

/* Responsive design */
@media (max-width: 1200px) {
    .main-container {
        flex-direction: column;
    }

    .menu-section,
    .content-area {
        width: 100%;
        position: static;
    }

    .learning-modes-section,
    .dashboard-section {
        width: 100%;
        position: static;
    }

    .category-content {
        flex-direction: column;
    }

    .level-image {
        width: 120px;
        height: 120px;
    }

    .roleplay-content {
        flex-direction: column;
    }

    .roleplay-image,
    .start-btn {
        width: 100%;
    }

    #chat-view.active {
        flex-direction: column;
    }

    .chat-section,
    .chat-info-section {
        width: 100%;
    }

    .chat-container {
        height: 60vh;
    }
}

@media (max-width: 768px) {
    .main-container {
        padding: 1rem;
        gap: 1rem;
    }

    .mode-card {
        flex-direction: column;
        text-align: center;
    }

    .mode-image {
        order: -1;
    }

    .top-banner {
        padding: 1rem;
    }

    .logo {
        height: 40px;
    }

    .login-btn {
        padding: 0.5rem 1.5rem;
        font-size: 0.9rem;
    }

    .lang-switcher-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }

    .lang-flag {
        width: 18px;
        height: 18px;
    }

    #currentLangLabel {
        display: none;
    }
}
