:root {
    --bg-body: #ebedf0;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-muted: #64748b;
    --accent: #000000;
    --border: #e2e8f0;
    --input-bg: #f8fafc;
    --radius: 16px;

    --c-new-text: #475569;
    --c-new-bg: #f1f5f9;
    --c-learning-text: #c2410c;
    --c-learning-bg: #fff7ed;
    --c-learned-text: #15803d;
    --c-learned-bg: #f0fdf4;

    --font-stack: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; -webkit-tap-highlight-color: transparent; }

body {
    font-family: var(--font-stack);
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

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

.sidebar {
    width: 260px;
    min-width: 260px;
    background: white;
    padding: 24px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    z-index: 10;
}

.logo { font-size: 22px; font-weight: 800; margin-bottom: 40px; letter-spacing: -0.5px; }

.nav-menu { display: flex; flex-direction: column; gap: 8px; flex: 1; }

.nav-item {
    border: none;
    background: transparent;
    text-align: left;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; gap: 12px;
    transition: 0.2s;
}

.nav-item:hover { color: var(--text-main); background: var(--bg-body); }
.nav-item.active { background: var(--accent); color: white; }

.btn-sidebar-add {
    margin-top: auto;
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    background: #e2e8f0;
    color: var(--text-main);
    border: none;
    font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    white-space: nowrap;
}
.btn-sidebar-add:hover { background: #cbd5e1; }

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    min-width: 0;
    position: relative;
}

.view { display: none; max-width: 900px; margin: 0 auto; animation: fade 0.3s; }
.view.active { display: block; }
@keyframes fade { from{opacity:0; transform:translateY(10px)} to{opacity:1; transform:translateY(0)} }

.header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 10px; }
h1 { font-size: 28px; font-weight: 700; }

h3 { margin: 0 0 15px 0; font-size: 18px; font-weight: 700; }

.streak-badge {
    background: white; padding: 6px 14px;
    border-radius: 20px; font-weight: 600; font-size: 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    white-space: nowrap;
}

.card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
}

.card-header-row { display: flex; justify-content: space-between; margin-bottom: 12px; }
.progress-track { background: var(--bg-body); height: 10px; border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { background: var(--accent); height: 100%; width: 0%; transition: width 0.5s; border-radius: 6px; }
.progress-label { text-align: right; font-size: 13px; font-weight: 500; color: var(--text-muted); }
.edit-icon { cursor: pointer; color: var(--text-muted); font-size: 14px; padding: 5px;}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card { text-align: center; padding: 24px; display: flex; flex-direction: column; justify-content: center; }
.stat-num { font-size: 28px; font-weight: 800; margin-bottom: 5px; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }

.training-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
    margin-bottom: 24px;
}

.control-group {
    display: flex;
    flex-direction: column;
}

.control-group.full-width { grid-column: span 2; }

.control-group label {
    display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text-muted);
}

.amount-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

.count-selector {
    display: flex; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; flex: 1;
}

.count-btn {
    flex: 1; padding: 12px 0; background: white; border: none;
    border-right: 1px solid var(--border); cursor: pointer; font-size: 14px; font-weight: 500;
    transition: 0.1s; color: var(--text-muted);
}
.count-btn:last-child { border-right: none; }
.count-btn.active { background: #f8fafc; font-weight: 700; color: var(--text-main); }

.custom-select {
    width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--border);
    background: white; font-size: 14px; outline: none; cursor: pointer; color: var(--text-main);
}

.custom-input {
    width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--border);
    background: white; font-size: 14px; outline: none;
}
.custom-input:focus { border-color: #94a3b8; }

.custom-input.small-input {
    width: 60px; text-align: center; padding: 12px 5px;
}

.multi-select-wrapper {
    width: 100%; min-height: 46px; border: 1px solid var(--border); border-radius: 12px;
    background: white; padding: 5px 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    cursor: text; position: relative;
}
.multi-select-wrapper:focus-within { border-color: #94a3b8; }

.chips-container { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
    background: var(--text-main); color: white; padding: 4px 10px; border-radius: 6px;
    font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px;
}
.chip i { cursor: pointer; font-size: 12px; opacity: 0.7; }
.chip i:hover { opacity: 1; }

.ghost-input {
    border: none; outline: none; flex: 1; min-width: 120px; font-size: 14px; padding: 6px 0;
    background: transparent;
}

.suggestions-dropdown {
    position: absolute; top: 100%; left: 0; width: 100%;
    background: white; border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); margin-top: 5px; z-index: 50;
    max-height: 200px; overflow-y: auto; display: none;
}
.suggestion-item {
    padding: 10px 15px; cursor: pointer; font-size: 14px; color: var(--text-main);
    border-bottom: 1px solid var(--input-bg);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: #f8fafc; }
.suggestion-meta { color: var(--text-muted); font-size: 11px; margin-left: 5px; }

.btn-black-large {
    width: 100%; background: var(--accent); color: white;
    padding: 16px; border-radius: 14px; border: none;
    font-weight: 600; font-size: 16px; cursor: pointer;
    transition: transform 0.1s;
}
.btn-black-large:active { transform: scale(0.98); }

.dictionary-controls {
    display: flex; justify-content: space-between;
    margin-bottom: 20px; gap: 15px; flex-wrap: wrap;
}
.filter-pill {
    padding: 10px 14px; background: white; border-radius: 12px;
    border: 1px solid var(--border); font-weight: 500; font-size: 14px; cursor: pointer;
    flex-shrink: 0;
}

.search-row-combined {
    flex: 1; min-width: 200px; display: flex; gap: 10px; align-items: center;
}
.search-wrap { position: relative; flex: 1; }
.search-wrap i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-wrap input {
    width: 100%; padding: 12px 12px 12px 40px; border-radius: 12px;
    border: 1px solid var(--border); font-size: 14px; background: white;
}

.btn-icon-danger {
    background: white; border: 1px solid #fee2e2; color: #ef4444;
    width: 44px; height: 44px; border-radius: 12px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: 0.2s;
}
.btn-icon-danger:hover { background: #fee2e2; }

.btn-float-reset {
    position: fixed; bottom: 30px; right: 30px;
    width: 45px; height: 45px; background: white;
    border: 1px solid #fee2e2; color: #ef4444; border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    z-index: 90; transition: 0.2s; font-size: 16px;
}
.btn-float-reset:hover { transform: rotate(-90deg); background: #fef2f2; }

/* FIX: Align View All correctly */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.section-header h3 {
    margin: 0;
}
.btn-link {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
    padding: 0;
}
.btn-link:hover {
    color: var(--text-main);
    text-decoration: underline;
}

.recent-section { margin-top: 30px; padding-bottom: 80px; }

.word-list { display: flex; flex-direction: column; gap: 12px; }
.word-item {
    background: white; padding: 16px 20px; border-radius: 16px;
    border: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center;
    transition: 0.1s; gap: 15px;
}
.word-item:active { background: #f9fafb; }

.w-main { flex: 1; min-width: 0; cursor: pointer; }
.w-main strong {
    font-size: 16px; display: block; margin-bottom: 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.w-trans {
    color: var(--text-muted); font-size: 14px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

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

.tag-badge {
    background: #f1f5f9; padding: 4px 8px; border-radius: 6px;
    font-size: 11px; font-weight: 600; color: #475569;
    white-space: nowrap; max-width: 80px; overflow: hidden; text-overflow: ellipsis;
}
.source-badge {
    background: transparent; border: 1px solid var(--border); padding: 3px 8px; border-radius: 6px;
    font-size: 11px; color: var(--text-muted); font-weight: 500;
    white-space: nowrap; max-width: 60px; overflow: hidden; text-overflow: ellipsis;
}
.source-badge i { font-size: 10px; margin-right: 3px; }

.status-badge {
    padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 600;
    text-transform: capitalize; cursor: pointer; transition: 0.2s;
    display: flex; align-items: center; gap: 4px;
    white-space: nowrap;
}

.st-new { background-color: var(--c-new-bg); color: var(--c-new-text); }
.st-learning { background-color: var(--c-learning-bg); color: var(--c-learning-text); }
.st-learned { background-color: var(--c-learned-bg); color: var(--c-learned-text); }

.action-icons { display: flex; gap: 15px; margin-left: 5px; }
.action-icons i { color: #cbd5e1; font-size: 16px; padding: 5px; }

.empty-state {
    text-align: center; color: var(--text-muted); padding: 30px 20px;
    background: white; border-radius: 16px; border: 2px dashed var(--border);
    font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s ease;
    margin-top: 10px; width: 100%;
}
.empty-state:hover { background: var(--input-bg); border-color: #cbd5e1; color: var(--text-main); }

.learning-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; gap: 15px;}
.btn-back {
    border: 1px solid var(--border); background: white; width: 40px; height: 40px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-main); font-size: 16px;
}
.progress-bar-thin {
    flex: 1; height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden;
}
#session-progress { height: 100%; background: var(--text-main); transition: width 0.3s; }

.flashcard-container { display: flex; justify-content: center; flex: 1; }
.flashcard {
    background: white; width: 100%; max-width: 600px; min-height: 400px;
    border-radius: 24px; border: 1px solid var(--border);
    box-shadow: 0 4px 25px rgba(0,0,0,0.03);
    display: flex; flex-direction: column; padding: 30px; text-align: center; position: relative;
}
.fc-top { position: absolute; top: 24px; left: 24px; }
.fc-tag { background: #f1f5f9; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 12px; color: #475569; }
.fc-center { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; padding: 20px 0; }
#fc-word { font-size: 36px; font-weight: 800; margin-bottom: 15px; line-height: 1.2; }
#fc-translation { color: #2563eb; font-size: 22px; margin-bottom: 12px; font-weight: 500; }
#fc-example { font-style: italic; color: var(--text-muted); font-size: 16px; line-height: 1.5; }

.btn-black-pill {
    background: var(--accent); color: white; padding: 16px 32px;
    border-radius: 30px; border: none; font-weight: 600; cursor: pointer;
    font-size: 16px; width: 100%;
}
.btn-result { flex: 1; padding: 16px; border-radius: 14px; border: 1px solid transparent; font-weight: 600; cursor: pointer; font-size: 16px; }
.btn-bad { background: #fee2e2; color: #991b1b; }
.btn-good { background: #dcfce7; color: #166534; }

.mobile-nav {
    display: none;
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: white; border-top: 1px solid var(--border);
    padding: 10px 30px; justify-content: space-between; align-items: center;
    z-index: 500;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.m-nav-item {
    background: none; border: none; font-size: 24px; color: #94a3b8; cursor: pointer; padding: 10px;
}
.m-nav-item.active { color: var(--text-main); }

.m-nav-add {
    background: var(--text-main); color: white; width: 50px; height: 50px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 20px; box-shadow: 0 4px 10px rgba(0,0,0,0.2); cursor: pointer;
    transform: translateY(-20px);
}

#modal-message, #modal-confirm, #modal-delete-confirm, #modal-status, #modal-complete, #modal-danger-1, #modal-danger-2, #modal-goal, #modal-settings {
    z-index: 2000;
}

.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center;
    z-index: 1000; backdrop-filter: blur(4px); padding: 20px;
}
.modal-window {
    background: white; width: 100%; max-width: 450px; padding: 30px; border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.1);
    max-height: 90vh; overflow-y: auto;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from{opacity:0; transform:translateY(20px)} to{opacity:1; transform:translateY(0)} }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.close-icon { cursor: pointer; font-size: 24px; color: var(--text-muted); padding: 5px; }

.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.input-group input {
    width: 100%; padding: 14px; background: var(--input-bg);
    border: none; border-radius: 12px; font-size: 16px;
}
.input-group input:focus { background: white; outline: 1px solid #94a3b8; }

.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 30px; align-items: center; flex-wrap: wrap; }
.btn-white { background: white; border: 1px solid var(--border); padding: 12px 24px; border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 15px; }
.btn-black { background: var(--accent); color: white; border: none; padding: 12px 24px; border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 15px; }
.btn-red-text { background: none; border: none; color: #ef4444; font-weight: 600; cursor: pointer; margin-right: auto; padding: 10px; }
.btn-red-solid { background: #ef4444; color: white; border: none; padding: 12px 24px; border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 15px; }
.btn-red-solid:hover { background: #dc2626; }

.complete-modal { padding: 40px 30px; }
.complete-icon {
    font-size: 50px; margin-bottom: 15px;
    animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes pop { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.complete-modal h2 { font-size: 24px; font-weight: 800; margin-bottom: 8px; color: var(--text-main); }
.complete-modal p { color: var(--text-muted); font-size: 15px; margin-bottom: 30px; }

.complete-stats { display: flex; gap: 15px; margin-bottom: 30px; }
.c-stat-card {
    flex: 1; background: white; padding: 20px 10px; border-radius: 16px;
    border: 1px solid var(--border); box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.stat-big { font-size: 28px; font-weight: 800; color: var(--text-main); line-height: 1.2; }
.stat-small { font-size: 11px; text-transform: uppercase; color: #94a3b8; font-weight: 700; letter-spacing: 0.5px; margin-top: 4px; }
.streak-plus { color: #f59e0b; }

#modal-message .modal-window { border: 1px solid var(--border); box-shadow: 0 10px 40px rgba(0,0,0,0.15); }

.small-modal { max-width: 350px; }
.status-options { display: flex; flex-direction: column; gap: 12px; }
.status-btn {
    padding: 16px; border-radius: 12px; border: none;
    font-weight: 600; text-transform: capitalize; cursor: pointer; font-size: 16px;
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .app-container { flex-direction: column; }
    .main-content { padding: 20px; padding-bottom: 90px; }

    .header-row h1 { font-size: 24px; }
    .stats-grid { grid-template-columns: 1fr; gap: 12px; }
    .stat-card { padding: 16px; flex-direction: row; justify-content: space-between; align-items: center; text-align: left; }
    .stat-num { margin: 0; font-size: 20px; }

    .training-grid { grid-template-columns: 1fr; gap: 15px; }
    .control-group.full-width { grid-column: span 1; }

    .amount-row { flex-wrap: wrap; }
    .custom-input.small-input { width: 100%; flex: 1; }

    .word-item { padding: 16px; flex-direction: column; align-items: flex-start; gap: 10px; }
    .w-main { width: 100%; }
    .w-meta { width: 100%; justify-content: space-between; margin-top: 5px; }
    .action-icons { display: none; }

    .flashcard { min-height: 60vh; padding: 20px; }
    #fc-word { font-size: 32px; }

    .mobile-nav { display: flex; }
    .btn-float-reset { bottom: 85px; right: 20px; }

    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal-window {
        max-width: 100%; border-bottom-left-radius: 0; border-bottom-right-radius: 0;
        padding-bottom: 40px;
    }
}