:root {
    --bg-body: #0b0f17;
    --bg-card: #151c28;
    --bg-card-hover: #1c2637;
    --bg-input: #0f1521;

    --border-color: #232d3f;
    --border-focus: #3b82f6;

    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.25);
    --primary-hover: #2563eb;

    --accent-green: #10b981;
    --accent-green-bg: rgba(16, 185, 129, 0.15);
    --accent-purple: #8b5cf6;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;

    --radius-xl: 20px;
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 6px;

    --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.15);
    --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.3);

    --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.navbar {
    background: rgba(21, 28, 40, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 28px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-glow);
}

.brand-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 30%, var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    padding: 5px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: var(--shadow-glow);
}

.nav-btn .badge {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 700;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-subtle);
}

.btn-secondary.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.btn-success {
    background: var(--accent-green);
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: var(--accent-red);
    color: white;
}

.main-container {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
    flex: 1;
}

.page-section {
    display: none;
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-header {
    margin-bottom: 28px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.page-header h2 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

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

.metrics-banner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

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

.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.metric-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-main);
    font-family: var(--font-mono);
}

.metric-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.reader-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
}

@media (max-width: 992px) {
    .reader-layout {
        grid-template-columns: 1fr;
    }
}

.editor-box {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="password"],
textarea,
select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    user-select: text;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

textarea {
    height: 140px;
    resize: vertical;
    line-height: 1.6;
}

.audio-player-bar {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.player-speed {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.reader-display-box {
    background: var(--bg-input);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    min-height: 220px;
    font-size: 19px;
    line-height: 2;
    color: #e2e8f0;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.translation-display-box {
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: var(--radius-lg);
    padding: 24px;
    min-height: 120px;
    font-size: 17px;
    line-height: 1.8;
    color: #a7f3d0;
    user-select: text;
    margin-top: 10px;
}

.word {
    cursor: pointer;
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    display: inline-block;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.word:hover {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 0 12px var(--primary-glow);
}

.word.known-new,
.word.known-reviewing {
    background: var(--accent-green-bg);
    color: var(--accent-green);
    border-bottom: 2px solid var(--accent-green);
    font-weight: 600;
}

.word.known-mastered {
    background: rgba(59, 130, 246, 0.08);
    color: #93c5fd;
    border-bottom: 1px dashed #3b82f6;
}

.reader-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.active-text-info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.active-text-info h4 {
    font-size: 12px;
    color: var(--primary);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.active-text-info p {
    font-size: 16px;
    font-weight: 700;
    margin-top: 4px;
    color: var(--text-main);
}

.guest-banner {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(239, 68, 68, 0.15));
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.guest-banner-text p {
    font-size: 14px;
    color: #fde047;
    font-weight: 600;
}

.guest-banner-text span {
    font-size: 12px;
    color: var(--text-muted);
}

.flashcard-container {
    max-width: 650px;
    margin: 0 auto;
    perspective: 1000px;
}

.flashcard-filter-bar {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.flashcard {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-xl);
    min-height: 340px;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-card);
    position: relative;
}

.flashcard:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.flashcard-term {
    font-size: 32px;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--primary);
    margin-bottom: 12px;
    word-break: break-word;
    line-height: 1.3;
}

.flashcard-term.is-phrase {
    font-size: 24px;
    color: #a7f3d0;
}

.flashcard-def {
    font-size: 15px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-top: 16px;
}

.flashcard-trans {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-green);
    background: var(--accent-green-bg);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    margin-top: 16px;
    word-break: break-word;
}

.flashcard-type-tag {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.flashcard-hint {
    position: absolute;
    bottom: 16px;
    font-size: 12px;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.flashcard-controls {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 28px;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.text-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.text-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow-card);
}

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

.text-card-snippet {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dict-toolbar {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle);
}

.search-box input {
    width: 100%;
    padding-left: 42px;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: var(--bg-input);
    padding: 14px 18px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 16px 18px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.badge-word {
    font-weight: 700;
    font-size: 15px;
    color: var(--primary);
    font-family: var(--font-mono);
}

.badge-type {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    margin-left: 8px;
}

.type-word {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}

.type-phrase {
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
}

.badge-translation {
    color: var(--accent-green);
    font-weight: 600;
    background: var(--accent-green-bg);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.badge-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
}

.status-new {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.status-reviewing {
    background: rgba(245, 158, 11, 0.2);
    color: #fde047;
}

.status-mastered {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

#popup {
    display: none;
    position: absolute;
    background: rgba(21, 28, 40, 0.96);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-focus);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), var(--shadow-glow);
    padding: 20px;
    border-radius: var(--radius-xl);
    width: 340px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1000;
}

.popup-word {
    font-size: 22px;
    font-weight: 800;
    color: #ffffff;
    font-family: var(--font-mono);
}

.popup-pos {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 4px;
    margin: 4px 0 12px 0;
}

.popup-def {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.popup-trans {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--accent-green);
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.5;
}

.verb-forms-box {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: var(--radius-md);
    padding: 10px;
    font-size: 12px;
    margin-bottom: 16px;
}

.verb-forms-box strong {
    color: var(--primary);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 4px;
}

.verb-forms-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    color: var(--text-muted);
}

.verb-forms-grid span b {
    color: var(--text-main);
    font-family: var(--font-mono);
}

.popup-actions {
    display: flex;
    gap: 8px;
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 400px;
    padding: 32px;
    box-shadow: var(--shadow-card);
}

.modal-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 6px;
    text-align: center;
}

.modal-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 24px;
}

#toast {
    visibility: hidden;
    min-width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    text-align: center;
    border-radius: var(--radius-lg);
    padding: 14px 20px;
    position: fixed;
    right: 30px;
    bottom: 30px;
    z-index: 3000;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-card);
    opacity: 0;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

#toast.show {
    visibility: visible;
    opacity: 1;
    transform: translateY(-10px);
    border-color: var(--primary);
}