/* ========== Notes Page ========== */

/* Notes page overrides main padding */
#page-notes.active {
    display: flex !important;
    flex-direction: column;
    padding: 0;
    margin: -32px -36px;
    width: calc(100% + 72px);
    height: calc(100vh);
    overflow: hidden;
}

/* Container */
.notes-container {
    display: flex;
    flex: 1;
    min-height: 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    overflow: hidden;
}

/* ===== Left Panel (Sidebar) ===== */
.notes-sidebar {
    width: 280px;
    min-width: 280px;
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.notes-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--card-border);
}

.notes-sidebar-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.notes-sidebar-actions {
    display: flex;
    gap: 4px;
}

.notes-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.notes-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.15);
}

.notes-action-btn svg {
    width: 16px;
    height: 16px;
}

/* Search */
.notes-search {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--card-border);
}

.notes-search svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-secondary);
    flex-shrink: 0;
}

.notes-search input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
}

.notes-search input::placeholder {
    color: var(--text-secondary);
}

/* Tag Filter */
.notes-tag-filter {
    padding: 0 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.notes-tag-filter:not(:empty) {
    padding-top: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--card-border);
}

.tag-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    background: color-mix(in srgb, var(--chip-color, #6366f1) 6%, var(--card-bg));
    border: 1px solid color-mix(in srgb, var(--chip-color, #6366f1) 20%, var(--card-border));
    color: var(--text-secondary);
}

.tag-filter-chip:hover {
    background: color-mix(in srgb, var(--chip-color, #6366f1) 12%, var(--card-bg));
    border-color: color-mix(in srgb, var(--chip-color, #6366f1) 40%, var(--card-border));
    color: var(--text-primary);
}

.tag-filter-chip.active {
    background: color-mix(in srgb, var(--chip-color, #6366f1) 18%, var(--card-bg));
    border-color: color-mix(in srgb, var(--chip-color, #6366f1) 50%, var(--card-border));
    color: var(--text-primary);
}

.tag-filter-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chip-color, #6366f1);
    box-shadow: 0 0 6px color-mix(in srgb, var(--chip-color, #6366f1) 50%, transparent);
}

/* Tree View */
.notes-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.notes-tree::-webkit-scrollbar {
    width: 3px;
}

.notes-tree::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px 7px calc(12px + var(--depth, 0) * 16px);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.82rem;
    transition: all var(--transition);
    user-select: none;
    position: relative;
}

.tree-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.tree-item.active {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.tree-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.tree-item.search-match {
    background: rgba(48, 92, 222, 0.08);
}

.tree-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    stroke: var(--text-secondary);
}

.tree-chevron.collapsed {
    transform: rotate(-90deg);
}

.tree-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.tree-icon.folder {
    stroke: #f59e0b;
}

.tree-icon.note {
    stroke: var(--text-secondary);
}

.tree-item:hover .tree-icon.note {
    stroke: var(--accent);
}

.tree-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-children {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.tree-children.collapsed {
    max-height: 0 !important;
}

/* Drag & Drop */
.tree-item.drag-over {
    background: rgba(48, 92, 222, 0.15);
    border-top: 2px solid var(--accent);
}

.tree-item.dragging {
    opacity: 0.4;
}

/* ===== Right Panel (Editor) ===== */
.notes-editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.notes-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.notes-empty-state svg {
    width: 56px;
    height: 56px;
    stroke: rgba(255, 255, 255, 0.12);
    margin-bottom: 16px;
}

.notes-empty-state p {
    font-size: 0.95rem;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.notes-empty-state span {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.3);
}

/* Editor */
.notes-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.notes-title-input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    font-family: inherit;
    padding: 20px 24px 8px;
    width: 100%;
}

.notes-title-input::placeholder {
    color: var(--text-secondary);
}

/* Tags Area */
.notes-tags-area {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 4px 24px 12px;
    min-height: 32px;
}

.notes-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.note-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 100px;
    background: color-mix(in srgb, var(--tag-color, #6366f1) 6%, var(--card-bg));
    border: 1px solid color-mix(in srgb, var(--tag-color, #6366f1) 20%, var(--card-border));
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    animation: tagAppear 0.2s ease;
    transition: all var(--transition);
}

.note-tag:hover {
    background: color-mix(in srgb, var(--tag-color, #6366f1) 12%, var(--card-bg));
    border-color: color-mix(in srgb, var(--tag-color, #6366f1) 40%, var(--card-border));
}

.note-tag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tag-color, #6366f1);
    box-shadow: 0 0 6px color-mix(in srgb, var(--tag-color, #6366f1) 50%, transparent);
    flex-shrink: 0;
}

@keyframes tagAppear {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.note-tag-remove {
    width: 16px;
    height: 16px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    line-height: 1;
    transition: all var(--transition);
    padding: 0;
}

.note-tag-remove:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.notes-tag-input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.78rem;
    font-family: inherit;
    min-width: 100px;
}

.notes-tag-input::placeholder {
    color: var(--text-secondary);
}

/* Tag Dropdown */
.notes-tag-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 180px;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 100;
    padding: 4px;
    margin-top: 4px;
}

.notes-tag-dropdown::-webkit-scrollbar {
    width: 3px;
}

.notes-tag-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.tag-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
}

.tag-dropdown-item:hover {
    background: color-mix(in srgb, var(--tag-color, #6366f1) 12%, var(--card-bg));
}

.tag-dropdown-item .note-tag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tag-color, #6366f1);
    box-shadow: 0 0 6px color-mix(in srgb, var(--tag-color, #6366f1) 50%, transparent);
    flex-shrink: 0;
}

/* Toolbar */
.notes-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 8px 20px;
    border-top: 1px solid var(--card-border);
    border-bottom: 1px solid var(--card-border);
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all var(--transition);
    font-family: inherit;
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.toolbar-btn.active {
    background: var(--accent);
    color: #fff;
}

.toolbar-btn svg {
    width: 16px;
    height: 16px;
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--card-border);
    margin: 0 4px;
}

/* Diff Bar */
.notes-diff-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: rgba(48, 92, 222, 0.08);
    border-bottom: 1px solid rgba(48, 92, 222, 0.15);
    animation: diffBarSlide 0.3s ease;
}

@keyframes diffBarSlide {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.diff-bar-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.diff-bar-btn {
    padding: 5px 14px;
    border-radius: 6px;
    border: none;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.diff-bar-btn.accept {
    background: #22c55e;
    color: #fff;
}

.diff-bar-btn.accept:hover {
    background: #16a34a;
}

.diff-bar-btn.reject {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.diff-bar-btn.reject:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Content Area */
.notes-content {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.75;
    outline: none;
    min-height: 200px;
}

.notes-content::-webkit-scrollbar {
    width: 4px;
}

.notes-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.notes-content:empty::before {
    content: attr(data-placeholder);
    color: var(--text-secondary);
    font-style: italic;
    pointer-events: none;
}

/* Content Styling */
.notes-content h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 20px 0 12px;
    color: var(--text-primary);
}

.notes-content h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 16px 0 10px;
    color: var(--text-primary);
}

.notes-content h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 14px 0 8px;
    color: var(--text-primary);
}

.notes-content p {
    margin: 0 0 8px;
}

.notes-content ul, .notes-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.notes-content li {
    margin-bottom: 4px;
}

.notes-content code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    color: #e879f9;
}

.notes-content pre {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 12px 0;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
}

.notes-content pre code {
    background: none;
    padding: 0;
    color: #e2e8f0;
}

.notes-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.notes-content a:hover {
    opacity: 0.8;
}

.notes-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.85rem;
}

.notes-content table th,
.notes-content table td {
    border: 1px solid var(--card-border);
    padding: 8px 12px;
    text-align: left;
}

.notes-content table th {
    background: rgba(255, 255, 255, 0.04);
    font-weight: 600;
}

/* Note Tasks (inline) */
.note-task {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin: 6px 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    cursor: pointer;
    transition: all var(--transition);
}

.note-task:hover {
    background: rgba(255, 255, 255, 0.06);
}

.note-task-checkbox {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
    padding: 0;
}

.note-task-checkbox:hover {
    border-color: var(--accent);
}

.note-task-checkbox.checked {
    background: var(--accent);
    border-color: var(--accent);
}

.note-task-checkbox.checked svg {
    opacity: 1;
}

.note-task-checkbox svg {
    width: 11px;
    height: 11px;
    stroke: #fff;
    stroke-width: 3;
    opacity: 0;
}

.note-task-text {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.note-task.completed .note-task-text {
    text-decoration: line-through;
    opacity: 0.5;
}

/* Inline Diff Markers */
.diff-added {
    background: rgba(34, 197, 94, 0.15);
    border-left: 3px solid #22c55e;
    padding: 2px 8px;
    margin: 2px 0;
    border-radius: 0 4px 4px 0;
    position: relative;
}

.diff-removed {
    background: rgba(239, 68, 68, 0.12);
    border-left: 3px solid #ef4444;
    padding: 2px 8px;
    margin: 2px 0;
    border-radius: 0 4px 4px 0;
    text-decoration: line-through;
    color: rgba(255, 255, 255, 0.5);
    position: relative;
}

.diff-actions {
    display: inline-flex;
    gap: 4px;
    margin-left: 8px;
    vertical-align: middle;
}

.diff-action-btn {
    padding: 2px 8px;
    border-radius: 4px;
    border: none;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.diff-action-btn.accept {
    background: #22c55e;
    color: #fff;
}

.diff-action-btn.reject {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* ===== AI Bar ===== */
.notes-ai-bar {
    padding: 8px 16px;
    flex-shrink: 0;
    background: var(--card-bg);
}

.notes-ai-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 12px 16px;
    transition: border-color var(--transition);
}

.notes-ai-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(48, 92, 222, 0.1);
}

.notes-ai-icon {
    width: 22px;
    height: 22px;
    color: var(--accent);
    flex-shrink: 0;
}

.notes-ai-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
}

.notes-ai-input::placeholder {
    color: var(--text-secondary);
}

.notes-ai-input:disabled {
    opacity: 0.5;
}

.notes-ai-send {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.notes-ai-send:hover:not(:disabled) {
    background: #254bbf;
    transform: scale(1.05);
}

.notes-ai-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.notes-ai-send svg {
    width: 18px;
    height: 18px;
}

.notes-ai-send.loading {
    pointer-events: none;
}

.notes-ai-send.loading svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== Context Menu ===== */
.notes-context-menu {
    position: fixed;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 6px;
    min-width: 180px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    animation: ctxMenuAppear 0.15s ease;
}

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

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 14px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}

.context-menu-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.context-menu-item.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.context-menu-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    #page-notes.active {
        margin: -24px -16px;
        width: calc(100% + 32px);
        height: 100vh;
    }

    .notes-container {
        flex-direction: column;
    }

    .notes-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 220px;
        border-right: none;
        border-bottom: 1px solid var(--card-border);
    }

    .notes-editor-panel {
        min-height: 300px;
    }

    .notes-title-input {
        font-size: 1.2rem;
        padding: 16px 16px 8px;
    }

    .notes-tags-area {
        padding: 4px 16px 10px;
    }

    .notes-toolbar {
        padding: 6px 12px;
    }

    .notes-content {
        padding: 16px;
    }

    .notes-ai-input-wrapper {
        padding: 10px 12px;
    }

    .fc-header { flex-direction: column; gap: 10px; }
    .fc-header-actions { flex-wrap: wrap; }
    .fc-card-wrapper { padding: 10px; }
    .fc-card { max-width: 100%; height: 240px; }
    .fc-study-actions { flex-direction: column; gap: 8px; }
    .fc-rate-btn { width: 100%; }
    .exam-options { flex-direction: column; }
    .exam-top-bar { font-size: 0.78rem; }
    .exam-score-circle { width: 100px; height: 100px; }
    .exam-score-num { font-size: 1.8rem; }
}

/* ========== Flashcard & Exam Styles ========== */

/* Mode Buttons (active state) */
.toolbar-btn.mode-btn.active {
    background: var(--accent);
    color: #fff;
}

/* ===== Flashcard Panel ===== */
.fc-panel, .fc-study, .exam-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 20px 24px;
}

.fc-panel::-webkit-scrollbar,
.fc-study::-webkit-scrollbar,
.exam-panel::-webkit-scrollbar {
    width: 4px;
}

.fc-panel::-webkit-scrollbar-thumb,
.fc-study::-webkit-scrollbar-thumb,
.exam-panel::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

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

.fc-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

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

/* Shared Button Styles */
.fc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.fc-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.fc-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.fc-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.fc-btn.primary:hover { background: #254bbf; }

.fc-btn.success {
    background: rgba(34,197,94,0.12);
    border-color: rgba(34,197,94,0.3);
    color: #22c55e;
}
.fc-btn.success:hover { background: rgba(34,197,94,0.2); }

.fc-btn.ai {
    background: linear-gradient(135deg, rgba(168,85,247,0.12), rgba(59,130,246,0.12));
    border-color: rgba(168,85,247,0.3);
    color: #a855f7;
}
.fc-btn.ai:hover { background: linear-gradient(135deg, rgba(168,85,247,0.2), rgba(59,130,246,0.2)); }

.fc-btn.ghost {
    border: none;
    padding: 6px 12px;
}

/* ===== Card List ===== */
.fc-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.fc-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 40px 20px;
    opacity: 0.6;
}

.fc-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--card-border);
    transition: all 0.2s ease;
    animation: fcItemIn 0.25s ease;
}

@keyframes fcItemIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.fc-list-item:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.12);
}

.fc-item-front {
    flex: 1;
    font-size: 0.88rem;
    color: var(--text-primary);
    font-weight: 500;
}

.fc-item-back {
    flex: 1;
    font-size: 0.82rem;
    color: var(--text-secondary);
    border-left: 2px solid var(--card-border);
    padding-left: 12px;
}

.fc-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.fc-list-item:hover .fc-item-actions { opacity: 1; }

.fc-item-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.fc-item-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.fc-item-btn.delete:hover { background: rgba(239,68,68,0.15); color: #ef4444; }

.fc-item-difficulty {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.fc-item-difficulty.new { background: #6366f1; box-shadow: 0 0 8px rgba(99,102,241,0.4); }
.fc-item-difficulty.easy { background: #22c55e; box-shadow: 0 0 8px rgba(34,197,94,0.4); }
.fc-item-difficulty.ok { background: #f59e0b; box-shadow: 0 0 8px rgba(245,158,11,0.4); }
.fc-item-difficulty.hard { background: #ef4444; box-shadow: 0 0 8px rgba(239,68,68,0.4); }

/* ===== Flashcard Study Mode ===== */
.fc-study-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.fc-progress-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.fc-progress-info span {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.fc-progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
}

.fc-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #a855f7);
    border-radius: 3px;
    width: 0%;
    transition: width 0.4s ease;
}

.fc-card-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    perspective: 1200px;
}

.fc-card {
    width: 100%;
    max-width: 480px;
    height: 300px;
    cursor: pointer;
    position: relative;
}

.fc-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.fc-card-front, .fc-card-back {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    border-radius: 20px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    text-align: center;
    overflow-y: auto;
}

.fc-card-front {
    background: linear-gradient(145deg, rgba(48,92,222,0.12), rgba(99,102,241,0.08));
    border: 1px solid rgba(48,92,222,0.25);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.05);
}

.fc-card-back {
    background: linear-gradient(145deg, rgba(34,197,94,0.12), rgba(16,185,129,0.08));
    border: 1px solid rgba(34,197,94,0.25);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.05);
    transform: rotateY(180deg);
}

.fc-card-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    opacity: 0.5;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.fc-card-front p, .fc-card-back p {
    font-size: 1.15rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0;
    font-weight: 500;
}

.fc-study-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

.fc-rate-btn {
    padding: 12px 28px;
    border-radius: 12px;
    border: none;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fc-rate-btn.hard {
    background: rgba(239,68,68,0.12);
    color: #ef4444;
}
.fc-rate-btn.hard:hover { background: rgba(239,68,68,0.2); transform: translateY(-2px); }

.fc-rate-btn.ok {
    background: rgba(245,158,11,0.12);
    color: #f59e0b;
}
.fc-rate-btn.ok:hover { background: rgba(245,158,11,0.2); transform: translateY(-2px); }

.fc-rate-btn.easy {
    background: rgba(34,197,94,0.12);
    color: #22c55e;
}
.fc-rate-btn.easy:hover { background: rgba(34,197,94,0.2); transform: translateY(-2px); }

.fc-flip-hint {
    display: block;
    margin: 12px auto 0;
    padding: 8px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.fc-flip-hint:hover { opacity: 1; }

/* ===== Exam Panel ===== */
.exam-setup {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
}

.exam-setup h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 6px;
}

.exam-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0 0 24px;
}

.exam-options {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.exam-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.exam-option:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.12);
}

.exam-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.exam-count-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.exam-count-row input {
    width: 70px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: rgba(255,255,255,0.04);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    text-align: center;
    outline: none;
}

.exam-count-row input:focus {
    border-color: var(--accent);
}

.exam-start-btn {
    padding: 12px 36px;
    font-size: 0.95rem;
}

/* Exam Active */
.exam-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.exam-progress-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.exam-timer {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.exam-question-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.exam-q-card {
    width: 100%;
    max-width: 560px;
    padding: 28px 32px;
    border-radius: 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--card-border);
    text-align: center;
}

.exam-q-type {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 12px;
    opacity: 0.7;
}

.exam-q-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.exam-mc-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 560px;
}

.exam-mc-opt {
    padding: 12px 18px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: rgba(255,255,255,0.03);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

.exam-mc-opt:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.15);
}

.exam-mc-opt.selected {
    border-color: var(--accent);
    background: rgba(48,92,222,0.1);
}

.exam-mc-opt.correct {
    border-color: #22c55e;
    background: rgba(34,197,94,0.1);
    color: #22c55e;
}

.exam-mc-opt.wrong {
    border-color: #ef4444;
    background: rgba(239,68,68,0.1);
    color: #ef4444;
}

.exam-tf-options {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.exam-tf-btn {
    padding: 14px 36px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: rgba(255,255,255,0.03);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.exam-tf-btn:hover { background: rgba(255,255,255,0.06); }
.exam-tf-btn.selected { border-color: var(--accent); background: rgba(48,92,222,0.1); }
.exam-tf-btn.correct { border-color: #22c55e; background: rgba(34,197,94,0.1); color: #22c55e; }
.exam-tf-btn.wrong { border-color: #ef4444; background: rgba(239,68,68,0.1); color: #ef4444; }

.exam-written-input {
    width: 100%;
    max-width: 400px;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: rgba(255,255,255,0.04);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    text-align: center;
}

.exam-written-input:focus { border-color: var(--accent); }

.exam-next-btn {
    margin-top: 16px;
}

.exam-feedback {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    animation: fcItemIn 0.25s ease;
}

.exam-feedback.correct {
    color: #22c55e;
    background: rgba(34,197,94,0.1);
}

.exam-feedback.wrong {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
}

/* Exam Results */
.exam-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 0;
    gap: 20px;
}

.exam-score-circle {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, rgba(48,92,222,0.15), rgba(99,102,241,0.1));
    border: 3px solid var(--accent);
    box-shadow: 0 0 40px rgba(48,92,222,0.2);
    animation: scoreIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.exam-score-num {
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.exam-score-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.exam-result-stats {
    display: flex;
    gap: 24px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.exam-result-stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.exam-result-stat .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.exam-result-stat .dot.green { background: #22c55e; }
.exam-result-stat .dot.red { background: #ef4444; }
.exam-result-stat .dot.yellow { background: #f59e0b; }

.exam-wrong-list {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.exam-wrong-item {
    padding: 12px 16px;
    border-radius: 10px;
    background: rgba(239,68,68,0.06);
    border: 1px solid rgba(239,68,68,0.12);
    font-size: 0.82rem;
}

.exam-wrong-q { color: var(--text-primary); margin-bottom: 4px; font-weight: 500; }
.exam-wrong-a { color: #22c55e; }
.exam-wrong-u { color: #ef4444; font-size: 0.78rem; }

.exam-result-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.exam-history {
    width: 100%;
    max-width: 400px;
    margin-top: 24px;
}

.exam-history-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.exam-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--card-border);
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.exam-history-score {
    font-weight: 700;
    color: var(--text-primary);
}

