/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #1f2353;
    background: #f4f5fb;
    min-height: 100vh;
    margin: 0;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

/* Two-Column Layout System */
.app-layout {
    display: flex;
    min-height: 100vh;
    background: #f4f5fb;
}

.app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 300px;
    background: linear-gradient(135deg, #6a7dff 0%, #8855ff 60%, #b356ff 100%);
    color: #fff;
    overflow-y: auto;
    padding: 20px 18px;
    box-shadow: 4px 0 20px rgba(111, 90, 255, 0.25);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.app-main {
    margin-left: 300px;
    flex: 1;
    min-height: 100vh;
    background: #f4f5fb;
    position: relative;
}

.app-main .container {
    max-width: 960px;
    margin: 0 auto;
    padding: 80px 20px 60px;
}

/* Hamburger Menu (Mobile Only) */
.hamburger-menu {
    display: none; /* Hidden on desktop */
    position: fixed;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #6a7dff 0%, #8855ff 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    z-index: 1100;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 10px;
    box-shadow: 0 2px 12px rgba(104, 125, 255, 0.4);
    transition: all 0.3s ease;
}

.hamburger-menu:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(104, 125, 255, 0.5);
}

.hamburger-menu:active {
    transform: scale(0.95);
}

.hamburger-menu span {
    display: block;
    width: 20px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hamburger → X animation */
.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Sidebar Close Button (Mobile Only) */
.sidebar-close-btn {
    display: none; /* Hidden on desktop */
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 110;
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.sidebar-close-btn:active {
    transform: scale(0.95);
}

/* Sidebar Backdrop (Mobile Only) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* Sidebar Brand */
.sidebar-brand {
    margin-bottom: 0;
}

.sidebar-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-brand h1 {
    font-size: 26px;
    margin: 8px 0 2px;
    color: #fff;
}

.sidebar-tagline {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0;
}

/* Sidebar Stats */
.sidebar-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.sidebar-stat {
    background: rgba(255, 255, 255, 0.12);
    padding: 8px 10px;
    border-radius: 10px;
    backdrop-filter: blur(6px);
    transition: background 0.2s ease;
}

.sidebar-stat:hover {
    background: rgba(255, 255, 255, 0.18);
}

.sidebar-stat-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.75);
    display: block;
    margin-bottom: 1px;
}

.sidebar-stat-value {
    display: block;
    font-size: 20px;
    font-weight: 600;
    color: #fff;
}

/* Sidebar Controls */
.sidebar-controls {
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-controls label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.9);
}

.sidebar-controls .level-select {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    width: 100%;
}

.sidebar-controls .setting-description {
    color: rgba(255, 255, 255, 0.75);
    font-size: 10px;
    margin-top: 4px;
    line-height: 1.3;
}

/* Sidebar Generate Button */
.sidebar-generate-btn {
    width: 100%;
    margin-top: 4px;
}

/* Sidebar Resume Button */
.sidebar-resume-btn {
    width: 100%;
    margin-top: 8px;
    background: rgba(100, 60, 180, 0.6);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.sidebar-resume-btn:hover:not(:disabled) {
    background: rgba(100, 60, 180, 0.75);
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.sidebar-resume-btn:active:not(:disabled) {
    transform: translateY(0);
}

.sidebar-resume-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.sidebar-lesson-status {
    color: rgba(255, 255, 255, 0.85);
    text-align: left;
    font-size: 11px;
    min-height: 16px;
}

/* Sidebar History Section */
.sidebar-history {
    padding-top: 12px;
    margin-top: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 8px;
    font-weight: 600;
}

.completed-topics-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.completed-topics-loading {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    font-style: italic;
}

.completed-topic-item {
    background: rgba(255, 255, 255, 0.08);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    transition: background 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid rgba(255, 183, 134, 1);
    margin-bottom: 4px;
    gap: 6px;
}

.completed-topic-item:hover {
    background: rgba(255, 255, 255, 0.12);
}

.completed-topic-item .completed-topic-name {
    font-weight: 600;
    text-transform: capitalize;
    color: rgba(255, 214, 165, 1);
    flex-shrink: 0;
    font-size: 13px;
}

.completed-topic-item .completed-topic-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.completed-topics-empty {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    font-style: italic;
    padding: 6px 0;
}

/* User Menu Dropdown */
.user-menu-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 300;
}

.user-menu-trigger {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-menu-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.45);
}

.user-menu-trigger:active {
    transform: scale(0.98);
}

.user-menu-dropdown {
    position: absolute;
    top: 58px;
    right: 0;
    min-width: 280px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.2);
    padding: 16px;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.2s ease;
}

.user-menu-dropdown.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.user-menu-header {
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 8px;
}

.user-menu-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
    margin-bottom: 4px;
}

.user-menu-email {
    font-size: 14px;
    font-weight: 600;
    color: #1f2353;
    word-break: break-all;
}

.user-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-menu-action {
    width: 100%;
    padding: 10px 14px;
    background: #f4f5fb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #1f2353;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

.user-menu-action:hover:not(:disabled) {
    background: #e5e7ff;
    border-color: #c5c9ff;
}

.user-menu-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* User Input Section */
.user-input {
    background: white;
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.user-input input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
}

.user-input input:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f0f0f0;
    color: #666;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* Lesson Section */
.lesson-section {
    background: white;
    padding: 28px;
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
}

.lesson-overview {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.btn-generate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.3);
    position: relative;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

.btn-generate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-generate.is-loading {
    opacity: 0.85;
    cursor: wait;
}

.btn-generate.is-loading::after {
    content: "";
    position: absolute;
    right: 16px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    animation: spin 1s linear infinite;
}

.btn-generate.is-success {
    background: linear-gradient(135deg, #2ECC71 0%, #27AE60 100%);
}

.btn-generate.is-error {
    background: linear-gradient(135deg, #FF6B6B 0%, #D84343 100%);
}

.lesson-info {
    font-size: 14px;
    color: #666;
    min-height: 20px;
    text-align: center;
}

.lesson-overview-label {
    font-size: 12px;
    letter-spacing: 0.5px;
    color: #999;
    text-transform: uppercase;
}

.lesson-header h2 {
    font-size: 28px;
    color: #1f2353;
    margin-bottom: 6px;
}

.lesson-meta {
    font-size: 14px;
    color: #666;
}

/* Variant progress indicator */
.variant-progress {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.variant-label {
    display: block;
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.variant-dots {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.variant-dot {
    font-size: 1.25rem;
    cursor: default;
    transition: transform 0.2s;
}

.variant-dot.current {
    color: #3b82f6;
    font-size: 1.5rem;
    transform: scale(1.2);
}

.variant-dot.completed {
    color: #10b981;
}

.variant-dot.available {
    color: #cbd5e1;
}

.variant-dot:hover {
    transform: scale(1.3);
}

.variant-more {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-left: 0.25rem;
}

/* History page variant dots */
.topic-variant-summary {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.variant-dot-small {
    font-size: 0.875rem;
}

.variant-dot-small.completed {
    color: #10b981;
}

.variant-dot-small.available {
    color: #cbd5e1;
}

.lesson-summary {
    position: relative;
    border: 1px solid #edefff;
    border-radius: 16px;
    padding: 18px 22px;
    margin-bottom: 24px;
    background: #fdfdff;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.lesson-summary-top {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
}

.lesson-topic-summary {
    flex: 1;
}

.lesson-topic-label {
    font-size: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #999;
    margin-bottom: 4px;
}

.lesson-topic-title {
    font-size: 20px;
    font-weight: 600;
}

.lesson-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.lesson-progress-ring {
    --progress: 0%;
    --ring-color: #667eea;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: conic-gradient(var(--ring-color) var(--progress), #e5e7ff 0);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 0.3s ease;
}

.lesson-progress-ring.complete {
    --ring-color: #48bb78;
    animation: progress-pulse 1s ease-in-out;
}

.lesson-progress-ring::after {
    content: "";
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #fdfdff;
    position: absolute;
}

.lesson-progress-value {
    position: relative;
    font-size: 14px;
    font-weight: 600;
    color: #1f2353;
}

.lesson-progress-caption {
    font-size: 12px;
    color: #666;
}

.lesson-summary-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.lesson-updated {
    font-size: 13px;
    color: #666;
}

.lesson-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.filter-pill {
    border: 1px solid #dcdffd;
    background: #f4f5ff;
    color: #4c54c3;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-pill:hover {
    background: #e3e6ff;
    border-color: #c5c9ff;
}

.filter-pill.is-active {
    background: #667eea;
    border-color: #667eea;
    color: #fff;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.filter-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.3);
    color: #4c54c3;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    margin-left: 4px;
    min-width: 18px;
    text-align: center;
}

.filter-pill.is-active .filter-badge {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

/* Loading / States */
.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.error {
    text-align: center;
    padding: 40px 20px;
    color: #d32f2f;
}

.error p {
    margin-bottom: 20px;
    font-size: 16px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state p {
    font-size: 18px;
    margin-bottom: 10px;
}

.empty-sub {
    font-size: 14px;
    color: #999;
}

/* Words Container */
.words-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.word-card-container.is-filtered-out {
    display: none;
}

.word-card-container {
    perspective: 1000px;
    margin-bottom: 20px;
    min-height: 300px;
}

.word-card {
    position: relative;
    width: 100%;
    height: 300px;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    cursor: pointer;
}

.word-card[data-flipped="true"] {
    transform: rotateY(180deg);
}

.word-card.active-card .word-card-back {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.word-card-front,
.word-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 30px;
    background: white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

.word-card-back {
    transform: rotateY(180deg);
}

.word-card:hover .word-card-front,
.word-card:hover .word-card-back {
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    border-color: #667eea;
}

.word-english-large {
    font-size: 48px;
    font-weight: bold;
    color: #333;
    margin: 50px 0 30px 0;
    text-align: center;
}

.word-number {
    font-size: 12px;
    color: #999;
    margin-bottom: 15px;
    align-self: flex-start;
    position: absolute;
    top: 15px;
    left: 15px;
}

.word-pair {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 50px 0 10px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.word-english {
    font-size: 22px;
    font-weight: 600;
    color: #333;
}

.word-arrow {
    color: #667eea;
    font-size: 18px;
}

.word-translation {
    font-size: 22px;
    font-weight: 600;
    color: #667eea;
}

.word-pos {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 15px;
}

.word-example {
    font-size: 18px;
    color: #666;
    font-style: italic;
    margin-bottom: 20px;
    text-align: center;
    padding: 0 20px;
    max-width: 80%;
    line-height: 1.5;
}

.word-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.difficulty-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.difficulty-btn {
    padding: 8px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.difficulty-btn:hover {
    transform: translateY(-2px);
}

.difficulty-btn.easy {
    color: #4caf50;
}

.difficulty-btn.easy:hover,
.difficulty-btn.easy.selected {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
}

.difficulty-btn.hard {
    color: #f44336;
}

.difficulty-btn.hard:hover,
.difficulty-btn.hard.selected {
    background: #f44336;
    color: white;
    border-color: #f44336;
}

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

.difficulty-btn.saved {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.report-btn {
    padding: 4px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: transparent;
    color: #999;
    font-size: 11px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s;
}

.report-btn:hover {
    background: #fff3cd;
    color: #856404;
    border-color: #ffeeba;
    transform: translateY(-1px);
}

.review-badge {
    background: #fff3cd;
    color: #856404;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin: 8px 0;
    display: inline-block;
    border: 1px solid #ffeeba;
    position: absolute;
    top: 15px;
    right: 15px;
}

.review-card {
    border-left: 4px solid #ffc107;
}

.review-card .word-card-front,
.review-card .word-card-back {
    border-color: #ffc107;
    background: linear-gradient(to right, #fffef7 0%, white 100%);
}

html {
    scroll-behavior: smooth;
}

.hidden {
    display: none !important;
}

/* Mobile Responsive - Two Column Layout */
@media (max-width: 1024px) {
    /* Show hamburger menu on mobile */
    .hamburger-menu {
        display: flex;
        top: calc(15px + env(safe-area-inset-top, 0px));
    }

    /* Show close button inside sidebar on mobile */
    .sidebar-close-btn {
        display: block;
    }

    /* Sidebar becomes slide-in overlay on mobile */
    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 85%;
        max-width: 300px;
        height: 100vh;
        overflow-y: auto;
        padding: 60px 18px 20px;
        padding-top: calc(60px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        border-radius: 0;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1050;
    }

    /* Sidebar visible state */
    .app-sidebar.sidebar-open {
        transform: translateX(0);
    }

    /* Main content full width on mobile */
    .app-main {
        margin-left: 0;
        margin-top: 0;
        padding-top: 0;
    }

    .app-main .container {
        padding: 20px 15px 40px;
        padding-top: calc(20px + env(safe-area-inset-top, 0px));
    }

    /* Compact sidebar layout for mobile */
    .sidebar-brand h1 {
        font-size: 26px;
    }

    .sidebar-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .sidebar-stat {
        padding: 8px 10px;
    }

    .sidebar-stat-value {
        font-size: 18px;
    }

    /* User menu adjustments */
    .user-menu-container {
        top: 16px;
        right: 16px;
    }

    .user-menu-trigger {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }

    /* Fix hamburger overlap - add left padding for hamburger space */
    .lesson-header {
        padding-left: 80px;
    }

    .lesson-summary {
        padding-left: 80px;
    }
}

@media (max-width: 768px) {
    .lesson-summary-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .lesson-filters {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
    }

    /* Reduce card height - less cramped */
    .word-card-container {
        min-height: 320px; /* Increased for better content fit */
    }

    .word-card {
        height: 320px; /* Increased for better content fit */
    }

    /* Better content spacing inside cards */
    .word-card-front,
    .word-card-back {
        padding: 16px; /* Was 20px */
        justify-content: space-between; /* Better vertical distribution */
    }

    .word-english-large {
        font-size: 32px; /* Was 36px */
        margin: 35px 0 20px 0; /* More top space to avoid overlap */
    }

    .word-english,
    .word-translation {
        font-size: 18px;
    }

    .word-example {
        font-size: 15px; /* Was 17px */
        line-height: 1.5;
        padding: 0 8px; /* Was 0 10px */
    }

    /* Add bottom padding to container for bottom nav */
    .app-main .container {
        padding-bottom: 80px; /* Space for bottom nav */
    }

    /* Compact sticky header for mobile */
    .lesson-summary {
        padding: 8px 12px 8px 80px; /* Compact, with space for hamburger */
        margin-bottom: 8px;
        min-height: 60px;
    }

    .lesson-summary-top {
        flex-direction: row !important; /* Override column layout */
        align-items: center;
        gap: 8px;
        flex-wrap: nowrap;
    }

    /* Tiny progress circle */
    .lesson-progress {
        flex-direction: column;
        gap: 0;
    }

    .lesson-progress-ring {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }

    .lesson-progress-value {
        font-size: 10px;
    }

    .lesson-progress-caption {
        display: none; /* Hide "Mastered" text */
    }

    /* Topic text - minimal */
    .lesson-topic-summary {
        flex: 1;
        min-width: 0; /* Allow text truncation */
    }

    .lesson-topic-label {
        font-size: 10px;
        margin-bottom: 2px;
    }

    .lesson-topic-title {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Hide complete button from sticky (moved to bottom) */
    .btn-complete-lesson {
        display: none;
    }

    .completion-hint {
        display: none;
    }

    /* Filter pills - compact */
    .lesson-filters {
        gap: 4px;
    }

    .filter-pill {
        font-size: 11px;
        padding: 4px 10px;
    }

    .difficulty-buttons {
        flex-direction: row;
        width: 100%;
        gap: 8px;
        justify-content: center;
    }

    .difficulty-btn {
        flex: 0 0 auto;
        min-height: 32px;
        font-size: 10px;
        padding: 4px 12px;
    }

    /* Mobile modal sizing improvements */
    .modal-content {
        width: 95%;
        max-width: none;
        padding: 20px;
        margin: 10px auto;
    }

    .settings-modal-content {
        width: 95%;
        max-width: none;
        max-height: 85vh;
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }

    .modal-header {
        padding: 15px 15px 10px;
    }

    .modal-body {
        padding: 15px;
    }

    /* Touch-friendly buttons */
    .filter-btn {
        min-height: 44px;
        padding: 10px 20px;
    }

    .user-menu-trigger {
        width: 44px;
        height: 44px;
    }
}

.level-select {
    width: 100%;
    padding: 8px 10px;
    margin: 4px 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.level-select:hover {
    border-color: #667eea;
}

.level-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-description {
    color: #666;
    font-size: 10px;
    margin-top: 4px;
    line-height: 1.3;
}

/* ============================================================================
   Lesson Completion Feature
   ============================================================================ */

/* Complete Lesson Button - in sticky header */
.btn-complete-lesson {
    background: #10b981;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 16px;
    white-space: nowrap;
}

.btn-complete-lesson:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2);
}

.btn-complete-lesson:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-complete-lesson.enabled {
    animation: pulse-green 2s infinite;
}

.btn-complete-lesson.completed {
    background: #059669;
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2); }
    50% { box-shadow: 0 6px 12px rgba(16, 185, 129, 0.4); }
}

/* Completion Hint Styles */
.completion-hint {
    font-size: 12px;
    color: #6b7280;
    margin-top: 8px;
    text-align: center;
    white-space: nowrap;
    transition: color 0.3s ease;
}

.completion-hint.enabled {
    color: #10b981;
    font-weight: 600;
}

.completion-hint.complete {
    color: #48bb78;
    font-weight: 700;
}

/* Modal Base Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: 12px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.2s ease-out;
}

.modal-content h3 {
    margin: 0 0 16px 0;
    font-size: 1.5rem;
    color: #1f2937;
}

.modal-content p {
    color: #6b7280;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: center;
}

/* Achievement Modal (celebration) */
.achievement-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2100;
    animation: fadeIn 0.3s;
}

.achievement-modal.hidden {
    display: none;
}

.achievement-modal-content {
    background: white;
    padding: 48px;
    border-radius: 16px;
    max-width: 500px;
    text-align: center;
    animation: scaleIn 0.3s;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
}

.achievement-modal-content h2 {
    margin: 0 0 32px 0;
    font-size: 2rem;
    color: #1f2937;
}

.achievement-item {
    margin-bottom: 24px;
}

.achievement-icon-large {
    font-size: 64px;
    display: block;
    margin-bottom: 16px;
}

.achievement-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.achievement-description {
    color: #6b7280;
    font-size: 1rem;
    margin: 0;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Success Banner */
.success-banner {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(72, 187, 120, 0.3);
    z-index: 1500;
    animation: slideInDown 0.5s ease-out;
    display: none;
}

.success-banner.visible {
    display: block;
}

/* Confetti */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: 0;
    z-index: 1400;
    animation: confetti-fall 3s linear forwards;
}

/* Celebration Animations */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes progress-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(72, 187, 120, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(72, 187, 120, 0);
    }
}

@keyframes confetti-fall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(500px) rotate(720deg);
    }
}

/* Settings Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none !important;
}

.settings-modal-content {
    background: white;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 12px;
    padding: 24px;
    animation: scaleIn 0.2s ease-out;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #1f2937;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.modal-close-btn:hover {
    background-color: #f5f5f5;
}

.settings-tabs {
    display: flex;
    gap: 10px;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
}

.settings-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.settings-tab.active {
    color: #FF6B35;
    border-bottom-color: #FF6B35;
}

.settings-tab-content {
    display: none;
}

.settings-tab-content.active {
    display: block;
}

.settings-section {
    margin-bottom: 20px;
}

.settings-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.settings-section select,
.settings-section input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
}

.settings-info {
    padding: 12px;
    background-color: #f5f9ff;
    border-left: 4px solid #4A90E2;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #555;
}

.tier-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 15px;
    background-color: #e3f2fd;
    color: #1976d2;
}

/* Topics List */
.topics-list {
    max-height: 400px;
    overflow-y: auto;
}

.topic-category {
    margin-bottom: 20px;
}

.topic-category h4 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #333;
}

.topics-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topic-chip {
    display: inline-block;
    padding: 6px 12px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 16px;
    font-size: 13px;
    color: #555;
}

.topic-chip.selected {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #FF6B35;
    color: white;
    border-color: #FF6B35;
}

.topic-remove-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topic-remove-btn:hover {
    opacity: 0.8;
}

/* Topic Cloud */
.topic-cloud {
    margin: 20px 0;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
}

.topic-cloud p {
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
}

.topic-cloud-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topic-cloud-chip {
    padding: 8px 16px;
    background-color: white;
    border: 2px solid #4A90E2;
    border-radius: 20px;
    font-size: 13px;
    color: #4A90E2;
    cursor: pointer;
    transition: all 0.2s;
}

.topic-cloud-chip:hover {
    background-color: #4A90E2;
    color: white;
}

/* Input Group */
.input-group {
    display: flex;
    gap: 10px;
}

.input-group input {
    flex: 1;
}

.input-group button {
    flex-shrink: 0;
}

/* Selected Topics List */
.selected-topics-list {
    min-height: 100px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-content: flex-start;
}

.empty-state {
    color: #999;
    font-style: italic;
}

/* Subscription Info */
.subscription-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 8px;
    margin-bottom: 20px;
}

.subscription-status span:first-child {
    font-weight: 600;
    color: #333;
}

.subscription-status span:last-child {
    padding: 6px 12px;
    border-radius: 16px;
    font-weight: 600;
    background-color: #4A90E2;
    color: white;
}

/* Modal Actions */
.modal-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-secondary {
    padding: 10px 20px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #e0e0e0;
}

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

/* Achievement Badges (in sidebar) */
.achievement-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 6px;
    transition: all 0.2s;
}

.achievement-badge:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateX(2px);
}

.achievement-badge .achievement-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.achievement-badge .achievement-text {
    flex: 1;
    min-width: 0;
}

.achievement-badge .achievement-name {
    font-weight: 600;
    margin: 0 0 2px 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.95);
}

.achievement-badge .achievement-desc {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
    line-height: 1.3;
}

/* Badge (count indicator) */
.badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.25);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Difficult Words List */
.difficult-words-list {
    margin-bottom: 0;
    max-height: 180px;
    overflow-y: auto;
}

.difficult-word-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border-left: 2px solid rgba(255, 100, 100, 0.8);
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 4px;
    gap: 6px;
}

.difficult-word-item .word {
    font-weight: 600;
    color: rgba(255, 200, 200, 1);
    flex-shrink: 0;
    font-size: 13px;
}

.difficult-word-item .translation {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Achievements List */
.achievements-list {
    max-height: 280px;
    overflow-y: auto;
}

/* Sidebar Section */
.sidebar-section {
    margin-bottom: 0;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

/* Empty State */
.empty-state {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    margin: 0;
    font-style: italic;
}

/* ============================================================
   HISTORY PAGE STYLES
   ============================================================ */

/* Section Link Styles (Clickable Sidebar Titles) */
.section-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.section-link:hover {
    color: rgba(255, 255, 255, 1);
    transform: translateX(2px);
}

.section-link .badge {
    transition: background 0.2s ease;
}

.section-link:hover .badge {
    background: rgba(255, 255, 255, 0.25);
}

/* User Menu Action Link */
.user-menu-action {
    background: none;
    border: none;
    padding: 12px 16px;
    text-align: left;
    width: 100%;
    cursor: pointer;
    color: #374151;
    font-size: 14px;
    transition: background 0.15s;
    text-decoration: none;
    display: block;
}

.user-menu-action:hover {
    background: #f3f4f6;
}

/* Sidebar Navigation Link */
.sidebar-nav-link {
    display: block;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.sidebar-nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(-2px);
}

/* Sidebar Quick Stats */
.sidebar-quick-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    margin: 0;
}

.quick-stat-icon {
    font-size: 16px;
}

/* History Page Header */
.history-header {
    margin-bottom: 32px;
}

.history-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.history-subtitle {
    font-size: 16px;
    color: #6b7280;
    margin: 0;
}

/* Tab Navigation */
.history-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0;
    overflow-x: auto;
}

.history-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s ease;
    white-space: nowrap;
    margin-bottom: -2px;
}

.history-tab:hover {
    color: #374151;
    background: #f9fafb;
}

.history-tab.active {
    color: #8b5cf6;
    border-bottom-color: #8b5cf6;
    background: #faf5ff;
}

.tab-icon {
    font-size: 18px;
}

.tab-label {
    font-weight: 600;
}

.tab-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.history-tab.active .tab-count {
    background: #8b5cf6;
    color: white;
}

/* Tab Content Panels */
.history-tab-content {
    display: none;
}

.history-tab-content.active {
    display: block;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Loading State */
.loading-state {
    text-align: center;
    color: #9ca3af;
    padding: 48px 24px;
    font-size: 14px;
}

/* Empty State (in modals/tabs) */
.empty-state-message {
    text-align: center;
    padding: 64px 24px;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-message p {
    color: #9ca3af;
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
}

/* Difficult Word Item (Full Page Version) */
.difficult-word-item-full {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: white;
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.difficult-word-item-full:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.difficult-word-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.difficult-word-english {
    font-weight: 700;
    font-size: 18px;
    color: #1f2937;
}

.difficult-word-translation {
    font-size: 16px;
    color: #6b7280;
}

.difficult-word-example {
    font-size: 14px;
    color: #6b7280;
    font-style: italic;
    margin: 4px 0;
    padding-left: 12px;
    border-left: 2px solid #e5e7eb;
}

.difficult-word-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 8px;
}

.difficult-word-topic {
    background: #f3f4f6;
    padding: 4px 10px;
    border-radius: 4px;
    color: #4b5563;
    font-weight: 500;
    text-transform: capitalize;
}

.difficult-word-pos {
    font-style: italic;
    color: #9ca3af;
}

/* Achievement Item (Full Page Version) */
.achievement-item-full {
    display: flex;
    gap: 16px;
    align-items: center;
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.achievement-item-full:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateX(4px);
}

.achievement-icon-full {
    font-size: 48px;
    flex-shrink: 0;
}

.achievement-info {
    flex: 1;
}

.achievement-name {
    font-weight: 700;
    font-size: 18px;
    color: #1f2937;
    margin-bottom: 4px;
}

.achievement-desc {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* Completed Topic Item (Full Page Version) */
.completed-topic-item-full {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    background: white;
    border-left: 4px solid #8b5cf6;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.completed-topic-item-full:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.completed-topic-name {
    font-weight: 700;
    font-size: 18px;
    color: #1f2937;
    text-transform: capitalize;
}

.completed-topic-variants {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.variant-badge {
    background: #ede9fe;
    color: #7c3aed;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
}

/* Responsive Design for History Page */
@media (max-width: 768px) {
    .history-header h1 {
        font-size: 24px;
    }

    .history-subtitle {
        font-size: 14px;
    }

    .history-tabs {
        gap: 4px;
    }

    .history-tab {
        padding: 10px 12px;
        font-size: 13px;
    }

    .tab-icon {
        font-size: 16px;
    }

    .tab-label {
        display: none;
    }

    .difficult-word-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .difficult-word-english {
        font-size: 16px;
    }

    .difficult-word-translation {
        font-size: 14px;
    }

    .achievement-item-full {
        flex-direction: column;
        align-items: flex-start;
    }

    .achievement-icon-full {
        font-size: 36px;
    }

    .achievement-name {
        font-size: 16px;
    }

    .completed-topic-item-full {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .completed-topic-name {
        font-size: 16px;
    }
}

/* Lessons Tab - Simple List */

.lesson-list-item {
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.lesson-list-item:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.lesson-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.lesson-list-topic {
    font-weight: 600;
    font-size: 16px;
    color: #1f2937;
}

.lesson-list-date {
    font-size: 14px;
    color: #6b7280;
}

.lesson-list-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #6b7280;
    margin-top: 8px;
}

.lesson-list-variant {
    margin-top: 8px;
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
}

.lesson-completed .lesson-list-topic {
    color: #059669;
}

/* Mobile Responsive - Completion Features */
@media (max-width: 768px) {
    .completion-hint {
        font-size: 11px;
        margin-top: 6px;
    }

    .success-banner {
        top: 60px;
        font-size: 16px;
        padding: 12px 24px;
    }
}

@media (max-width: 480px) {
    .completion-hint {
        font-size: 10px;
        white-space: normal;
    }

    /* Even smaller cards for tiny phones */
    .word-card-container {
        min-height: 280px; /* Increased for better content fit */
    }

    .word-card {
        height: 280px; /* Increased for better content fit */
        padding: 12px;
    }

    .word-card-front,
    .word-card-back {
        padding: 12px;
    }

    .word-english-large {
        font-size: 26px; /* Was 28px */
        margin: 30px 0 15px 0; /* More top space to avoid overlap */
    }

    .word-dutch {
        font-size: 18px; /* Was 20px */
    }

    .word-example {
        font-size: 13px; /* Was 14px */
    }

    .difficulty-btn {
        padding: 4px 10px;
        font-size: 10px;
    }

    /* Reduce container padding on small phones */
    .app-main .container {
        padding: 15px 10px 80px; /* Adjusted for bottom nav */
    }

    /* Hide lesson header on very small screens */
    .lesson-header {
        padding: 12px;
    }

    .lesson-header h2 {
        font-size: 20px;
    }

    /* Compact sticky header */
    .lesson-topic-summary {
        display: none; /* Hide "Vocabulary level" label to save space */
    }
}

/* ============================================================================
   History Page - Filter Bars
   ============================================================================ */

/* Lessons Control Bar */
.lessons-control-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 18px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
}

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

.control-label {
    font-weight: 600;
    color: #1f2353;
    font-size: 14px;
}

.control-select {
    padding: 8px 12px;
    padding-right: 36px;
    border: 2px solid #e2e5f1;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236a7dff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    color: #1f2353;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: all 0.2s ease;
    min-width: 180px;
}

.control-select:hover {
    border-color: #6a7dff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(106, 125, 255, 0.15);
}

.control-select:focus {
    outline: none;
    border-color: #6a7dff;
    box-shadow: 0 0 0 3px rgba(106, 125, 255, 0.1);
}

.control-count {
    color: #6b7280;
    font-size: 13px;
    margin-left: auto;
}

/* Lessons Category Groups */
.lessons-category-group {
    margin-bottom: 32px;
}

.lessons-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.lessons-category-header:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.3);
}

.lessons-category-header.collapsed .category-toggle {
    transform: rotate(-90deg);
}

.category-title-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.category-icon {
    font-size: 24px;
}

.category-title {
    font-weight: 700;
    font-size: 18px;
}

.category-lesson-count {
    font-size: 14px;
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 12px;
}

.category-toggle {
    transition: transform 0.2s ease;
    font-size: 16px;
}

.lessons-category-content {
    margin-left: 24px;
    padding-left: 16px;
    border-left: 3px solid #e0e7ff;
    transition: all 0.3s ease;
}

.lessons-category-content.collapsed {
    display: none;
}

/* Lessons Topic Groups (when grouped) */
.lessons-topic-group {
    margin-bottom: 16px;
}

.lessons-topic-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.lessons-topic-header:hover {
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
}

.lessons-topic-title {
    font-weight: 600;
    font-size: 16px;
}

.lessons-topic-count {
    background: rgba(255, 255, 255, 0.25);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

.lessons-topic-toggle {
    font-size: 18px;
    transition: transform 0.3s ease;
    margin-left: 12px;
}

.lessons-topic-header.collapsed .lessons-topic-toggle {
    transform: rotate(-90deg);
}

.lessons-topic-lessons {
    padding-left: 8px;
    transition: all 0.3s ease;
}

.lessons-topic-lessons.collapsed {
    display: none;
}

/* Lesson topic names - not clickable */
.lesson-list-topic {
    cursor: default;
}

.lesson-list-topic:hover {
    color: inherit;
    text-decoration: none;
}

/* Keep filter-label for difficult words */
.filter-label {
    font-weight: 600;
    color: #1f2353;
    font-size: 14px;
}

.topic-filter-select {
    padding: 8px 12px;
    padding-right: 36px;
    border: 2px solid #e2e5f1;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236a7dff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    color: #1f2353;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: all 0.2s ease;
    min-width: 180px;
}

.topic-filter-select:hover {
    border-color: #6a7dff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(106, 125, 255, 0.15);
}

.topic-filter-select:focus {
    outline: none;
    border-color: #6a7dff;
    box-shadow: 0 0 0 3px rgba(106, 125, 255, 0.1);
}

.filter-result-count {
    color: #6b7280;
    font-size: 13px;
    margin-left: auto;
}

/* Difficult Words Filter Bar */
.difficult-words-filter-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 18px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-filter-select {
    padding: 8px 12px;
    padding-right: 36px;
    border: 2px solid #e2e5f1;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236a7dff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    color: #1f2353;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: all 0.2s ease;
    min-width: 140px;
}

.date-filter-select:hover {
    border-color: #6a7dff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(106, 125, 255, 0.15);
}

.date-filter-select:focus {
    outline: none;
    border-color: #6a7dff;
    box-shadow: 0 0 0 3px rgba(106, 125, 255, 0.1);
}

/* Topic Group Sections */
.difficult-words-topic-group {
    margin-bottom: 24px;
}

.topic-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #6a7dff 0%, #8855ff 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.topic-group-header:hover {
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(106, 125, 255, 0.3);
}

.topic-group-title {
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.topic-group-count {
    background: rgba(255, 255, 255, 0.25);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

.topic-group-toggle {
    font-size: 18px;
    transition: transform 0.3s ease;
}

.topic-group-header.collapsed .topic-group-toggle {
    transform: rotate(-90deg);
}

.topic-group-words {
    padding-left: 8px;
    transition: all 0.3s ease;
}

.topic-group-words.collapsed {
    display: none;
}

/* Enhanced Difficult Word Item */
.difficult-word-item-full {
    border-left: 4px solid #6a7dff;
}

.difficult-word-learned-date {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
    margin-top: 4px;
}

.difficult-word-review-info {
    display: flex;
    gap: 12px;
    margin-top: 6px;
    font-size: 13px;
    color: #4b5563;
    flex-wrap: wrap;
}

.review-info-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Mobile responsive for filters */
@media (max-width: 768px) {
    .lessons-control-bar,
    .difficult-words-filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .control-group,
    .filter-group {
        width: 100%;
        justify-content: space-between;
    }

    .control-select,
    .topic-filter-select,
    .date-filter-select {
        flex: 1;
        min-width: 0;
    }

    .control-count,
    .filter-result-count {
        margin-left: 0;
        text-align: center;
    }

    .lessons-topic-header,
    .topic-group-header {
        font-size: 14px;
        padding: 10px 12px;
    }

    .lessons-topic-title,
    .topic-group-title {
        font-size: 14px;
    }

    .difficult-word-review-info {
        font-size: 12px;
    }
}

/* ============================================================================
   Enhanced Filter Controls - Toggle Switch & Count Badges
   ============================================================================ */

/* Toggle Switch Component */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

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

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e2e5f1;
    border-radius: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-input:checked + .toggle-slider {
    background: linear-gradient(135deg, #6a7dff 0%, #8855ff 100%);
    box-shadow: 0 0 0 3px rgba(106, 125, 255, 0.1);
}

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

.toggle-input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(106, 125, 255, 0.2);
}

.toggle-input:focus:checked + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(106, 125, 255, 0.3);
}

.toggle-input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Toggle Label */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #1f2353;
    font-size: 14px;
    user-select: none;
}

.toggle-icon {
    font-size: 16px;
}

/* Count Badge Component */
.count-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #6a7dff 0%, #8855ff 100%);
    color: white;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(106, 125, 255, 0.25);
    margin-left: auto;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.count-badge:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(106, 125, 255, 0.35);
}

.count-badge-icon {
    font-size: 16px;
    animation: badge-icon-pulse 2s ease-in-out infinite;
}

.count-badge-value {
    font-weight: 600;
    letter-spacing: 0.3px;
}

@keyframes badge-icon-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Filter/Control Icons */
.control-icon,
.filter-icon {
    font-size: 16px;
    margin-right: 2px;
}

/* Hide deprecated count styles (replaced by .count-badge) */
.control-count {
    display: none;
}

.filter-result-count {
    display: none;
}

/* Mobile Responsive - Enhanced Controls */
@media (max-width: 768px) {
    .toggle-switch {
        width: 40px;
        height: 22px;
    }

    .toggle-slider::before {
        height: 16px;
        width: 16px;
    }

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

    .count-badge {
        padding: 5px 12px;
        font-size: 12px;
    }

    .count-badge-icon {
        font-size: 14px;
    }

    .toggle-label,
    .control-icon,
    .filter-icon {
        font-size: 13px;
    }
}

/* Ultra-compact for very small screens */
@media (max-width: 480px) {
    .toggle-label span:first-child {
        display: none; /* Hide "Group by topic" text, keep icon */
    }

    .control-icon,
    .filter-icon {
        display: none; /* Hide label icons to save space */
    }

    .count-badge {
        padding: 4px 10px;
        font-size: 11px;
    }
}

/* ============================================================================
   Mobile Bottom Action Bar
   ============================================================================ */

/* Mobile Bottom Action Bar - Complete Lesson + Progress */
.mobile-bottom-action-bar {
    display: none; /* Hidden on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e2e5f1;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 500;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

@media (max-width: 1024px) {
    .mobile-bottom-action-bar {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    /* Hide old bottom nav (if any references remain) */
    .mobile-bottom-nav {
        display: none !important;
    }
}

.bottom-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.bottom-progress-ring {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: conic-gradient(#6a7dff 0deg, #e2e5f1 0deg);
    transition: background 0.3s ease;
}

.bottom-progress-value {
    font-size: 12px;
    font-weight: 600;
    color: #1f2353;
    position: relative;
    z-index: 1;
    background: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-progress-label {
    font-size: 11px;
    color: #6b7280;
    font-weight: 500;
}

.btn-bottom-complete {
    flex: 1;
    background: linear-gradient(135deg, #6a7dff 0%, #8855ff 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(106, 125, 255, 0.3);
}

.btn-bottom-complete:disabled {
    background: #e2e5f1;
    color: #9ca3af;
    box-shadow: none;
    cursor: not-allowed;
}

.btn-bottom-complete:not(:disabled):active {
    transform: scale(0.97);
}

/* Active tap state (iOS-style) */
.bottom-nav-item:active {
    transform: scale(0.95);
    opacity: 0.7;
}

/* ============================================================================
   Mobile Animations & Polish
   ============================================================================ */

/* Smooth page transitions */
.words-container {
    transition: opacity 0.3s ease;
}

.word-card {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
}

/* iOS-style tap states for buttons */
.btn-complete-lesson:active,
.difficulty-btn:active {
    transform: scale(0.97);
}

/* Swipe hint styling (mobile-only) */
.swipe-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: rgba(31, 35, 83, 0.4);
    font-style: italic;
    transition: opacity 0.3s ease;
}

@media (min-width: 1024px) {
    .swipe-hint {
        display: none; /* Desktop uses buttons, not swipes */
    }
}

/* Haptic-like feedback - remove tap highlight on mobile */
@media (max-width: 1024px) {
    .bottom-nav-item,
    .word-card,
    .btn-complete-lesson {
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }
}

/* ============================================================================
   Topics Browsing Page
   ============================================================================ */

.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    padding-bottom: 2rem;
}

.topic-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.topic-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #3b82f6;
}

.topic-card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.topic-card-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.topic-card-title-group {
    flex: 1;
}

.topic-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 0.25rem 0;
}

.topic-card-path {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
}

.topic-card-description {
    color: #4b5563;
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.topic-card-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.topic-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.topic-badge.difficulty-beginner {
    background-color: #dbeafe;
    color: #1e40af;
}

.topic-badge.difficulty-intermediate {
    background-color: #fef3c7;
    color: #92400e;
}

.topic-badge.difficulty-advanced {
    background-color: #fee2e2;
    color: #991b1b;
}

.topic-badge.in-progress {
    background-color: #fef3c7;
    color: #92400e;
}

.topic-badge.completed {
    background-color: #d1fae5;
    color: #065f46;
}

.topic-card-progress {
    margin-bottom: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);
    transition: width 0.3s ease;
    border-radius: 9999px;
}

.progress-text {
    font-size: 0.75rem;
    color: #6b7280;
}

.topic-card-button {
    width: 100%;
    padding: 0.75rem;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.topic-card-button:hover {
    background-color: #2563eb;
}

.topic-card-button:active {
    transform: scale(0.98);
}

.search-input {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-nav-link {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.5rem 0;
    transition: color 0.2s ease;
}

.sidebar-nav-link:hover {
    color: white;
}

/* Compact Icon Bar Navigation */
.sidebar-nav-compact {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.nav-icon-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.nav-icon {
    font-size: 1.5rem;
}

@media (max-width: 768px) {
    .topics-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Premium Category Selection
   ======================================== */

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.category-card {
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 1rem;
    background: white;
    transition: all 0.2s ease;
}

.category-card:hover {
    border-color: #4A90E2;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.1);
}

.category-card.selected {
    border-color: #4A90E2;
    background: #f5f9ff;
}

.category-card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.category-checkbox {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.category-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
    cursor: pointer;
}

.category-icon {
    font-size: 1.5rem;
}

.category-info {
    flex: 1;
}

.category-name {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.category-path {
    margin: 0;
    font-size: 0.875rem;
    color: #666;
}

.category-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e0e0e0;
}

.topic-pill {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #f0f0f0;
    border-radius: 12px;
    font-size: 0.75rem;
    color: #555;
}

/* ========================================
   Custom Categories Section
   ======================================== */

.custom-category-input-wrapper {
    margin-bottom: 2rem;
}

.custom-category-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.custom-category-input:focus {
    outline: none;
    border-color: #4A90E2;
}

.input-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn-icon {
    margin-right: 0.25rem;
}

.custom-categories-list-wrapper {
    margin-top: 1.5rem;
}

.subsection-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 1rem 0;
}

.custom-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.custom-category-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.custom-category-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.custom-category-icon {
    font-size: 1.25rem;
}

.custom-category-name {
    flex: 1;
    font-weight: 500;
}

.custom-category-remove-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    transition: all 0.2s;
}

.custom-category-remove-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* ========================================
   Error State Styling
   ======================================== */

.error-state {
    padding: 2rem;
    text-align: center;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
}

.error-message {
    color: #856404;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.loading-state {
    color: #666;
    font-style: italic;
    padding: 1rem;
}

.empty-state {
    color: #999;
    font-style: italic;
    padding: 1rem;
}

/* ========================================
   IMPROVED SETTINGS PAGE DESIGN
   ======================================== */

/* Header with Save Button */
.settings-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

.settings-header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    flex-wrap: wrap;
}

.settings-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.settings-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.settings-subtitle {
    margin: 0;
    font-size: 1.125rem;
    opacity: 0.95;
    font-weight: 400;
}

.settings-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-save {
    background: white;
    color: #667eea;
    border: none;
    padding: 0.875rem 1.75rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.btn-save:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    background: #f8f9ff;
}

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

.btn-save-icon {
    font-size: 1.25rem;
}

.save-status {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

.save-status.saving {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.save-status.success {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
}

.save-status.error {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
}

/* Section Cards */
.section-card {
    background: white;
    border-radius: 16px;
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    border: 2px solid #f0f0f0;
    transition: all 0.3s ease;
}

.section-card:hover {
    border-color: #e0e0e0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.premium-feature {
    border-color: #e8d5ff;
    background: linear-gradient(135deg, #fdfbff 0%, #f8f4ff 100%);
}

.premium-feature:hover {
    border-color: #d5b8ff;
    box-shadow: 0 4px 16px rgba(118, 75, 162, 0.15);
}

/* Section Headers */
.section-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f5f5f5;
}

.section-icon-wrapper {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.section-icon-wrapper.premium-icon {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.3);
}

.section-icon {
    font-size: 1.5rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    color: #1a1a1a;
}

.section-subtitle {
    font-size: 0.9375rem;
    color: #666;
    margin: 0;
    font-weight: 400;
}

/* Improved Category Cards */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
    margin-top: 0;
}

.category-card {
    border: 2px solid #e5e5e5;
    border-radius: 14px;
    padding: 1.25rem;
    background: white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.category-card:hover {
    border-color: #667eea;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
    transform: translateY(-4px);
}

.category-card:hover::before {
    opacity: 1;
}

.category-card.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #f5f7ff 0%, #e8ecff 100%);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.2);
}

.category-card.selected::before {
    opacity: 1;
}

.category-card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.category-checkbox {
    margin-top: 6px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #667eea;
}

.category-label {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    flex: 1;
    cursor: pointer;
}

.category-icon {
    font-size: 1.75rem;
    line-height: 1;
}

.category-info {
    flex: 1;
}

.category-name {
    margin: 0 0 0.375rem 0;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #1a1a1a;
}

.category-path {
    margin: 0;
    font-size: 0.8125rem;
    color: #888;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.category-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #f0f0f0;
}

.topic-pill {
    display: inline-block;
    padding: 0.375rem 0.875rem;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    border-radius: 20px;
    font-size: 0.8125rem;
    color: #555;
    font-weight: 500;
    transition: all 0.2s ease;
}

.topic-pill:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.05);
}

/* Focus Track Select */
.track-select {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid #e5e5e5;
    border-radius: 10px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.track-select:hover {
    border-color: #667eea;
}

.track-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.help-text {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: #888;
    line-height: 1.5;
}

/* Tier Badge */
.tier-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.tier-badge-premium {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #1a1a1a;
}

.tier-badge-icon {
    font-size: 1.125rem;
}

/* ========================================
   FREE TIER: Radio Button Selection
   ======================================== */

.focus-track-radio-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.focus-track-radio {
    display: block;
    cursor: pointer;
}

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

.radio-content {
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    padding: 1.25rem;
    background: white;
    transition: all 0.3s ease;
}

.focus-track-radio:hover .radio-content {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.radio-input:checked + .radio-content {
    border-color: #667eea;
    background: linear-gradient(135deg, #f5f7ff 0%, #e8ecff 100%);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.2);
}

.radio-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.radio-icon {
    font-size: 2rem;
    line-height: 1;
}

.radio-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.25rem;
}

.radio-description {
    font-size: 0.9375rem;
    color: #666;
}

.radio-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.875rem;
    padding-top: 0.875rem;
    border-top: 1px solid #f0f0f0;
}

.category-tag {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    background: #f5f5f5;
    border-radius: 6px;
    font-size: 0.8125rem;
    color: #555;
    font-weight: 500;
}

.help-box {
    background: linear-gradient(135deg, #fff9e6 0%, #fff3d4 100%);
    border-left: 4px solid #ffc107;
    padding: 1.25rem;
    border-radius: 8px;
}

.help-box-title {
    font-weight: 600;
    color: #856404;
    margin: 0 0 0.75rem 0;
}

.help-box-list {
    margin: 0;
    padding-left: 1.25rem;
    color: #856404;
}

.help-box-list li {
    margin-bottom: 0.5rem;
}

.help-box-list li:last-child {
    margin-bottom: 0;
}

/* ========================================
   PREMIUM TIER: Hierarchical Tree
   ======================================== */

.hierarchy-help {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f5f7ff 0%, #e8ecff 100%);
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.hierarchy-badge {
    padding: 0.375rem 0.875rem;
    background: white;
    border: 2px solid #667eea;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #667eea;
}

.hierarchy-arrow {
    font-size: 1.25rem;
    color: #667eea;
    font-weight: bold;
}

.hierarchical-paths-container {
    border: 2px solid #f0f0f0;
    border-radius: 12px;
    background: white;
}

.hierarchy-path {
    border-bottom: 1px solid #f0f0f0;
}

.hierarchy-path:last-child {
    border-bottom: none;
}

.hierarchy-path.premium-path {
    background: linear-gradient(135deg, #fdfbff 0%, #f8f4ff 100%);
}

.hierarchy-level {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    transition: background 0.2s ease;
}

.hierarchy-level:hover {
    background: rgba(102, 126, 234, 0.05);
}

.hierarchy-level-path {
    padding: 1.25rem;
}

.hierarchy-level-category {
    padding-left: 3.5rem;
}

.hierarchy-level-topic {
    padding-left: 5.5rem;
    padding: 0.625rem 1rem 0.625rem 5.5rem;
}

.hierarchy-toggle {
    background: none;
    border: none;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.hierarchy-toggle:hover {
    color: #667eea;
}

.hierarchy-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    flex: 1;
    cursor: pointer;
}

.hierarchy-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #667eea;
    flex-shrink: 0;
}

/* Free tier radio button styles (same visual style as checkboxes) */
.hierarchy-radio-label {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    flex: 1;
    cursor: pointer;
}

.hierarchy-radio {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #667eea;
    flex-shrink: 0;
}

.hierarchy-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.hierarchy-info {
    flex: 1;
}

.hierarchy-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hierarchy-description {
    font-size: 0.875rem;
    color: #666;
}

.premium-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.hierarchy-children {
    border-top: 1px solid #f0f0f0;
}

.hierarchy-children.hidden {
    display: none;
}

.hierarchy-spacer {
    width: 24px;
}

.hierarchy-bullet {
    color: #999;
    font-size: 1.25rem;
    line-height: 1;
}

.hierarchy-topic-name {
    font-size: 0.9375rem;
    color: #555;
}

/* ========================================
   CUSTOM CATEGORIES
   ======================================== */

.custom-category-input-wrapper {
    margin-bottom: 1.5rem;
}

.btn-add-custom {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-add-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.custom-categories-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.empty-state-text {
    color: #999;
    font-style: italic;
    padding: 2rem;
    text-align: center;
}

.custom-category-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    background: linear-gradient(135deg, #f5f7ff 0%, #e8ecff 100%);
    border: 2px solid #d5d9ff;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.custom-category-item:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.custom-category-icon {
    font-size: 1.25rem;
}

.custom-category-name {
    flex: 1;
    font-weight: 500;
    color: #1a1a1a;
}

.custom-category-remove {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    color: #f44336;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.custom-category-remove:hover {
    background: #f44336;
    color: white;
    transform: scale(1.1);
}

/* ========================================
   UPGRADE CARD
   ======================================== */

.upgrade-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
}

.upgrade-content {
    text-align: center;
}

.upgrade-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.upgrade-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

.upgrade-description {
    font-size: 1.125rem;
    margin: 0 0 1.5rem 0;
    opacity: 0.95;
}

.upgrade-features {
    list-style: none;
    padding: 0;
    margin: 0 0 2rem 0;
    text-align: left;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.upgrade-features li {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 1rem;
}

.upgrade-features li:last-child {
    border-bottom: none;
}

.btn-upgrade {
    background: white;
    color: #667eea;
    border: none;
    padding: 1rem 2.5rem;
    border-radius: 12px;
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.btn-upgrade:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .settings-header-content {
        flex-direction: column;
    }

    .settings-title {
        font-size: 1.5rem;
    }

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

    .btn-save {
        width: 100%;
        justify-content: center;
    }

    .hierarchy-help {
        flex-wrap: wrap;
    }

    .tier-badge {
        order: -1;
        width: 100%;
        justify-content: center;
    }
}
