:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --timer-orange: #f97316;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 40px;
}

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-links li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-links li:hover, .nav-links li.active {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

.nav-links li i {
    width: 20px;
}

.user-info {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.streak {
    font-weight: 600;
    margin-bottom: 12px;
}

.xp-bar-container {
    font-size: 0.875rem;
}

.xp-progress {
    height: 8px;
    background-color: var(--secondary-color);
    border-radius: 4px;
    margin-top: 4px;
    overflow: hidden;
}

#xp-fill {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    padding: 32px;
    max-width: 95%;
    margin: 0 auto;
}

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

.quote {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Daily Plan Banner */
.daily-plan-card {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    color: white;
    padding: 24px;
    border-radius: var(--radius);
    display: flex;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 32px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.daily-progress-container {
    margin-top: 16px;
    background: rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: #38bdf8;
    width: 0%;
    transition: width 0.5s ease;
}

.daily-words-preview {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.preview-title {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 8px;
    opacity: 0.9;
}

.preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.preview-tag {
    background: rgba(56, 189, 248, 0.1);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.2);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    transition: all 0.2s ease;
    cursor: default;
}

.preview-tag:hover {
    background: rgba(56, 189, 248, 0.2);
    transform: translateY(-1px);
}

.preview-empty {
    font-size: 0.8rem;
    opacity: 0.8;
    font-style: italic;
}

.plan-icon {
    font-size: 2.4rem;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
    padding: 16px;
    border-radius: 16px;
}

.plan-content {
    flex: 1;
}

.plan-content h4 {
    margin-bottom: 6px;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

#plan-suggestion {
    font-size: 0.9rem;
    line-height: 1.5;
    opacity: 0.8;
    margin-bottom: 16px;
}

/* Grid Layout */
.learning-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

/* Cards */
.timer-card, .learning-card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

/* Timer Display */
.timer-card {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.timer-mode-selector {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
    background-color: var(--bg-main);
    padding: 4px;
    border-radius: 12px;
}

.mode-btn {
    padding: 8px 20px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.mode-btn.active {
    background-color: var(--bg-card);
    color: var(--primary-color);
    box-shadow: var(--shadow);
}

#timer-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

#timer-display {
    font-size: 4rem;
    font-weight: 800;
    color: var(--timer-orange);
    margin-bottom: 24px;
    font-variant-numeric: tabular-nums;
}

.timer-stages {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.timer-stages span {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    background-color: var(--secondary-color);
    color: var(--text-muted);
}

.timer-stages span.active {
    background-color: var(--timer-orange);
    color: white;
}

/* Buttons */
.primary-btn, .secondary-btn, .task-btn, .option-btn, .filter-btn {
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

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

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

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

.timer-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Learning Panel */
.task-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 24px 0;
}

.task-btn {
    background-color: var(--secondary-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
}

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

.task-btn small {
    font-weight: normal;
    opacity: 0.8;
}

.difficulty-picker {
    margin-top: 20px;
}

select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-main);
}

/* Word Card */
.word-card-container {
    perspective: 1000px;
    margin-bottom: 24px;
}

.word-card {
    width: 420px; /* Further increased width */
    height: 260px; /* Further increased height */
    margin: 0 auto; /* Center the card */
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    cursor: pointer;
}

.tally-display-left {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 1.2rem;
    color: var(--danger); /* Red for 'dislike' */
}

.tally-display-right {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.2rem;
    color: var(--success); /* Green for 'like' */
}

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

#word-practice-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    text-align: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.card-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    color: white;
    text-align: left;
    justify-content: flex-start;
    overflow-y: auto;
}

.card-back #word-meaning {
    color: white;
    font-size: 1.4rem;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 8px;
    width: 100%;
}

.card-back #word-definition, 
.card-back #word-example {
    color: rgba(255, 255, 255, 0.9);
}

.card-back .label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-item {
    margin-bottom: 10px;
    width: 100%;
    font-size: 0.9rem;
}

.card-item .label {
    font-weight: bold;
    opacity: 0.9;
    margin-right: 6px;
    display: inline-block;
    min-width: 45px;
    font-size: 0.8rem;
}

.card-item span:not(.label) {
    line-height: 1.3;
}

#current-word {
    font-size: 2rem;
    margin-bottom: 6px;
}

#word-phonetic {
    font-size: 0.9rem;
    opacity: 0.8;
}

#word-definition {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

#word-example {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-main);
}

.practice-controls {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 12px;
    margin-top: 24px; /* Add some space between card and buttons */
}

.rating-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.rate-btn {
    padding: 10px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.rate-btn[data-rating="again"] { background-color: #fee2e2; color: #ef4444; }
.rate-btn[data-rating="good"] { background-color: #dcfce7; color: #22c55e; }
.rate-btn[data-rating="easy"] { background-color: #dbeafe; color: #3b82f6; }

.rate-btn:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

/* Quiz Area */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 20px 0;
}

.option-btn {
    background-color: var(--secondary-color);
    text-align: left;
}

.option-btn.correct {
    background-color: var(--success);
    color: white;
}

.option-btn.incorrect {
    background-color: var(--danger);
    color: white;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.stat-item {
    background-color: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

.stat-item i {
    font-size: 1.5rem;
    color: var(--primary-color);
    background-color: var(--secondary-color);
    padding: 12px;
    border-radius: 12px;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Word List View */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.title-with-count {
    display: flex;
    align-items: center;
    gap: 12px;
}

.count-badge {
    background: var(--bg-card);
    color: var(--text-muted);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.word-filters {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 6px 16px;
    font-size: 0.875rem;
}

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

.word-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.word-item {
    background-color: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.word-item-info h4 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.word-list-by-difficulty {
    margin-top: 20px;
}

.difficulty-section {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
    overflow: hidden;
}

.difficulty-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background-color: var(--secondary-color);
    cursor: pointer;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.difficulty-header i {
    transition: transform 0.2s;
}

.difficulty-header.collapsed i {
    transform: rotate(-90deg);
}

.difficulty-content {
    padding: 0 20px 10px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
    max-height: 500px; /* Adjust as needed */
    overflow-y: auto;
    transition: max-height 0.3s ease-out;
}

.difficulty-content.collapsed {
    max-height: 0;
    padding-bottom: 0;
}

.difficulty-word-item {
    padding: 10px;
    border-bottom: 1px dashed var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.difficulty-word-item:last-child {
    border-bottom: none;
}

.difficulty-word-item h5 {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}

.difficulty-word-item span {
    font-size: 0.85rem;
    color: var(--text-muted);
}


.word-status {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 12px;
}

.status-learning { background-color: #fef3c7; color: #d97706; }
.status-mastered { background-color: #dcfce7; color: #16a34a; }
.status-unseen { background-color: #f1f5f9; color: #64748b; }

/* Stats Detailed */
.stats-detailed-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

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

.chart-card h3 {
    margin-bottom: 20px;
    font-size: 1rem;
    color: var(--text-muted);
}

#focus-chart {
    width: 100%;
    height: 200px;
}

.stats-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mini-stat {
    background-color: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.mini-stat .label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.mini-stat .value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Settings */
.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.setting-item {
    margin-bottom: 20px;
}

.setting-item label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.setting-item input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

/* Achievements */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.achievement-card {
    background-color: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    text-align: center;
    transition: all 0.3s;
    opacity: 0.5;
    filter: grayscale(1);
}

.achievement-card.unlocked {
    opacity: 1;
    filter: grayscale(0);
    border-color: var(--warning);
    background: linear-gradient(145deg, var(--bg-card), #fffbeb);
}

.achievement-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: block;
}

.achievement-card h4 {
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.achievement-card p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

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

.modal-content {
    background-color: var(--bg-card);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

.summary-stats {
    margin: 24px 0;
    text-align: left;
    background-color: var(--secondary-color);
    padding: 20px;
    border-radius: 12px;
}

.summary-stats p {
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

#theme-toggle {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.25rem;
    cursor: pointer;
}
