:root {
    --ui-font: 'Inter', system-ui, -apple-system, sans-serif;
    --code-font: 'JetBrains Mono', monospace;
    --border-radius: 14px;
    --transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);

    /* Accents — violet / magenta (dark UI) */
    --accent-blue: #c4b5fd;
    --accent-purple: #a78bfa;
    --accent-magenta: #e879f9;
    --accent-orange: #fdba74;
    --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 42%, #5b21b6 100%);
    --accent-gradient-hover: linear-gradient(135deg, #9333ea 0%, #6d28d9 55%, #4c1d95 100%);
    --accent-glow: 0 0 32px rgba(139, 92, 246, 0.35);

    /* Typography — high contrast on deep purple-black */
    --text-primary: #f4f4ff;
    --text-secondary: #b8bdd9;
    --text-muted: #8588a8;

    /* Surfaces */
    --bg-void: #020203;
    --bg-deep: #08050e;
    --bg-primary: rgba(12, 8, 22, 0.55);
    --bg-secondary: rgba(20, 12, 36, 0.82);
    --bg-card: rgba(26, 16, 44, 0.88);
    --bg-sidebar: rgba(8, 4, 16, 0.94);

    /* Page atmosphere: black → deep violet */
    --page-gradient: linear-gradient(
        168deg,
        #020105 0%,
        #0a0612 18%,
        #10081c 40%,
        #1a0f2e 62%,
        #12081f 82%,
        #06040b 100%
    );
    --page-vignette: radial-gradient(ellipse 120% 100% at 50% -10%, rgba(124, 58, 237, 0.18) 0%, transparent 52%),
        radial-gradient(ellipse 90% 70% at 0% 100%, rgba(192, 38, 211, 0.1) 0%, transparent 45%);

    --border-color: rgba(167, 139, 250, 0.2);
    --border-strong: rgba(216, 201, 255, 0.35);

    --glass-bg: rgba(22, 14, 40, 0.82);
    --glass-border: rgba(167, 139, 250, 0.28);
    --shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
    --shadow-soft: 0 8px 28px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 8px 32px rgba(91, 33, 182, 0.25);
}

[data-theme="light"] {
    --accent-blue: #4f46e5;
    --accent-purple: #7c3aed;
    --accent-magenta: #c026d3;
    --accent-orange: #ea580c;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #7c3aed 50%, #5b21b6 100%);
    --accent-gradient-hover: linear-gradient(135deg, #4f46e5 0%, #6d28d9 100%);
    --accent-glow: 0 4px 20px rgba(99, 102, 241, 0.18);

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --bg-void: #f8fafc;
    --bg-deep: #f1f5f9;
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #f1f5f9;

    --page-gradient: linear-gradient(180deg, #f8fafc 0%, #eef2ff 45%, #ffffff 100%);
    --page-vignette: none;

    --border-color: rgba(15, 23, 42, 0.1);
    --border-strong: rgba(15, 23, 42, 0.14);

    --glass-bg: rgba(255, 255, 255, 0.94);
    --glass-border: rgba(15, 23, 42, 0.08);
    --shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 4px 20px rgba(15, 23, 42, 0.06);
    --shadow-glow: 0 4px 24px rgba(99, 102, 241, 0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    color: var(--text-primary);
    font-family: var(--ui-font);
    line-height: 1.62;
    letter-spacing: 0.01em;
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    display: flex;
    overflow: hidden;
    transition: color 0.35s ease, background 0.45s ease;
    background-color: var(--bg-void);
    background-image: var(--page-vignette), var(--page-gradient);
    background-attachment: fixed;
    background-size: cover;
}

::selection {
    background: rgba(139, 92, 246, 0.45);
    color: #fff;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
    font-weight: 700;
}

a {
    color: var(--accent-purple);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-magenta);
}

/* Buttons */
button {
    font-family: var(--ui-font);
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-primary {
    background: var(--accent-gradient);
    color: #faf5ff;
    padding: 11px 22px;
    border-radius: var(--border-radius);
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: var(--accent-glow), var(--shadow-soft);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-primary:hover {
    transform: translateY(-2px);
    background: var(--accent-gradient-hover);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.45), var(--shadow-soft);
    filter: brightness(1.05);
}

.btn-secondary {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: var(--border-radius);
}

.btn-secondary:hover {
    background-color: var(--bg-card);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-danger {
    background-color: rgba(249, 115, 22, 0.1);
    color: var(--accent-orange);
    border: 1px solid rgba(249, 115, 22, 0.2);
    padding: 10px 20px;
    border-radius: var(--border-radius);
}

.btn-danger:hover {
    background-color: var(--accent-orange);
    color: white;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.theme-toggle:hover {
    color: var(--accent-magenta);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-glow);
    transform: rotate(15deg);
}

/* Inputs */
input,
select,
textarea {
    width: 100%;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 14px 20px;
    border-radius: var(--border-radius);
    outline: none;
    transition: var(--transition);
    font-family: var(--ui-font);
    margin-bottom: 12px;
}

input:focus,
textarea:focus {
    border-color: var(--accent-purple);
    background-color: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.22);
}

/* LOGIN SCREEN */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: var(--page-vignette), var(--page-gradient);
    background-attachment: fixed;
    background-size: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-card {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 22px;
    padding: 56px 52px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow), var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h2 {
    font-size: 28px;
    background: var(--accent-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.login-error {
    color: var(--accent-orange);
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
    display: none;
}

/* SIDEBAR */
.sidebar {
    width: 300px;
    min-height: 0;
    height: 100%;
    background: linear-gradient(180deg, rgba(10, 6, 20, 0.97) 0%, rgba(6, 3, 14, 0.98) 100%);
    border-right: 1px solid var(--border-color);
    box-shadow: inset -1px 0 0 rgba(167, 139, 250, 0.06);
    display: flex;
    flex-direction: column;
}

[data-theme="light"] .sidebar {
    background: var(--bg-sidebar);
    box-shadow: none;
}

.sidebar-header {
    flex-shrink: 0;
    padding: 22px 20px 18px;
}

.sidebar-header h2 {
    font-size: 17px;
    letter-spacing: -0.4px;
}

.sidebar-nav {
    flex: 0 0 auto;
    padding: 0 14px 6px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav .nav-section {
    margin-bottom: 0;
}

.sidebar-nav .nav-title {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.12em;
    margin: 0 10px 9px;
    font-weight: 700;
}

.sidebar-nav .nav-item {
    padding: 9px 14px;
    border-radius: calc(var(--border-radius) - 2px);
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 500;
    cursor: pointer;
}

.sidebar-nav .nav-item:hover,
.sidebar-nav .nav-item.active {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.sidebar-nav .nav-item.active {
    background: var(--accent-gradient);
    color: #faf5ff;
    box-shadow: var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.14em;
    margin: 0 12px 14px;
    font-weight: 700;
}

.category-count-badge {
    margin-left: auto;
    background: rgba(0, 0, 0, 0.25);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .category-count-badge {
    background: rgba(0, 0, 0, 0.06);
    border-color: transparent;
}

.sidebar-footer {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px 18px;
    overflow-y: auto;
    overflow-x: hidden;
}

.logout-btn {
    flex-shrink: 0;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--border-radius);
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-weight: 500;
    font-size: 13px;
    margin-top: 0;
}

.logout-btn:hover {
    background: #ef4444;
    color: white;
}

/* SCRATCHPAD (GYORSJEGYZET) */
.scratchpad-container {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    padding: 12px 12px 10px;
    background: rgba(18, 10, 32, 0.55);
    border-radius: 14px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.scratchpad-container > .nav-title {
    flex-shrink: 0;
    margin: 0 2px 8px;
    font-size: 10px;
    letter-spacing: 0.12em;
}

[data-theme="light"] .scratchpad-container {
    background: rgba(0, 0, 0, 0.04);
    box-shadow: none;
}

#scratchpad {
    flex: 1 1 auto;
    min-height: 100px;
    width: 100%;
    height: auto;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--ui-font);
    font-size: 13px;
    resize: none;
    outline: none;
    line-height: 1.45;
    margin-bottom: 0;
}

#scratchpad-status {
    flex-shrink: 0;
    font-size: 10px;
    color: var(--text-secondary);
    text-align: right;
    margin-top: 6px;
    opacity: 0.6;
}

/* MAIN CONTENT */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(12, 8, 22, 0.35) 0%, transparent 38%);
}

[data-theme="light"] .main-content {
    background: var(--bg-primary);
}

.topbar {
    height: 96px;
    padding: 0 44px;
    display: flex;
    align-items: center;
    gap: 28px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .topbar {
    background: var(--bg-secondary);
    backdrop-filter: none;
    box-shadow: none;
}

.topbar-search-slot {
    flex-grow: 1;
    max-width: 600px;
    min-width: 0;
    position: relative;
}

.topbar-search-slot .search-container {
    max-width: none;
}

.search-container {
    flex-grow: 1;
    max-width: 600px;
    position: relative;
}

.search-container input {
    padding-left: 54px;
    padding-right: 48px;
    border-radius: 25px;
    background-color: var(--bg-primary);
}

.search-clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: rgba(139, 92, 246, 0.12);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.search-clear-btn:hover {
    color: var(--text-primary);
    background: rgba(139, 92, 246, 0.22);
    border-color: var(--border-color);
}

[data-theme="light"] .search-clear-btn {
    background: rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .search-clear-btn:hover {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-primary);
}

.search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.content-area {
    padding: 44px 48px 56px;
    overflow-y: auto;
    flex-grow: 1;
}

/* ARTICLE CARDS */
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 32px;
}

.article-card {
    background: linear-gradient(155deg, rgba(32, 20, 52, 0.92) 0%, rgba(14, 10, 26, 0.88) 100%);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    padding: 28px 30px;
    box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: var(--transition);
    cursor: pointer;
}

[data-theme="light"] .article-card {
    background: var(--bg-card);
    box-shadow: var(--shadow-soft);
}

.article-card:hover {
    transform: translateY(-6px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow), var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.article-category {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(167, 139, 250, 0.25);
    padding: 5px 12px;
    border-radius: 999px;
    display: inline-block;
    margin-bottom: 18px;
}

.article-title {
    font-size: 20px;
    margin-bottom: 12px;
}

.article-summary {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* LEARNING ROADMAP — témakör sáv (csak a Tanulási roadmap fülön) */
.learning-view-head {
    margin-bottom: 28px;
}

.learning-view-head__title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 6px;
    color: var(--text-primary);
}

.learning-view-head__hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 16px;
}

.learning-topic-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    box-shadow: var(--shadow-soft);
}

.learning-topic-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.22);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    --chip-accent: #06b6d4;
}

[data-theme="light"] .learning-topic-chip {
    background: rgba(15, 23, 42, 0.05);
}

.learning-topic-chip[data-kb-learning-topic-all] {
    --chip-accent: #8b5cf6;
}

.learning-topic-chip:hover {
    border-color: var(--chip-accent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--chip-accent) 40%, transparent);
}

.learning-topic-chip--active {
    border-color: var(--chip-accent);
    background: color-mix(in srgb, var(--chip-accent) 28%, transparent);
    color: #faf5ff;
    box-shadow: 0 0 18px color-mix(in srgb, var(--chip-accent) 30%, transparent);
}

[data-theme="light"] .learning-topic-chip--active {
    color: var(--text-primary);
    box-shadow: none;
}

.learning-topic-chip__name {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.learning-topic-chip__count {
    font-size: 11px;
    font-weight: 700;
    opacity: 0.9;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.28);
}

[data-theme="light"] .learning-topic-chip__count {
    background: rgba(15, 23, 42, 0.12);
}

/* MODALS */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(160deg, rgba(2, 1, 6, 0.88) 0%, rgba(30, 10, 48, 0.75) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

[data-theme="light"] .modal-overlay {
    background: rgba(15, 23, 42, 0.45);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--glass-bg);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    width: 95%;
    max-width: 960px;
    max-height: 90vh;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow), var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: var(--transition);
}

[data-theme="light"] .modal-content {
    background: var(--bg-secondary);
    backdrop-filter: none;
    border-color: var(--border-color);
    box-shadow: var(--shadow);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 36px 48px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(32, 20, 56, 0.55) 0%, rgba(14, 10, 24, 0.2) 100%);
}

[data-theme="light"] .modal-header {
    background: transparent;
}

.modal-body {
    padding: 48px;
    overflow-y: auto;
}

.modal-footer {
    padding: 28px 48px 32px;
    background: linear-gradient(180deg, rgba(18, 10, 32, 0.5) 0%, rgba(10, 6, 18, 0.75) 100%);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 20px;
}

[data-theme="light"] .modal-footer {
    background: var(--bg-card);
}

.modal-close {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-secondary);
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--border-strong);
}

/* EDITOR SPECIFIC STYLES */
.editor-toolbar {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    margin-bottom: 0;
    flex-wrap: wrap;
    align-items: center;
}

.toolbar-group {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.toolbar-btn:hover {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #faf5ff;
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
    box-shadow: var(--accent-glow);
}

#edit-content {
    width: 100%;
    height: 400px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 12px 12px;
    padding: 24px;
    color: var(--text-primary);
    font-family: var(--code-font);
    font-size: 15px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
}

#edit-content:focus {
    border-color: var(--accent-purple);
    background: var(--bg-card);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

/* KANBAN BOARD STYLES */
.kanban-board {
    display: flex;
    gap: 20px;
    padding: 20px 0;
    overflow-x: auto;
    align-items: flex-start;
    height: calc(100vh - 180px);
}

.kanban-column {
    flex: 0 0 300px;
    background: linear-gradient(180deg, rgba(24, 14, 42, 0.9) 0%, rgba(12, 8, 22, 0.92) 100%);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    max-height: 100%;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .kanban-column {
    background: var(--bg-secondary);
    box-shadow: none;
}

.kanban-column-header {
    padding: 14px 16px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    background: rgba(139, 92, 246, 0.08);
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
}

[data-theme="light"] .kanban-column-header {
    background: rgba(0, 0, 0, 0.04);
}

.kanban-cards {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex-grow: 1;
    min-height: 100px;
}

.kanban-card {
    background: rgba(10, 6, 20, 0.65);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.22s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .kanban-card {
    background: var(--bg-primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.kanban-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow), 0 6px 16px rgba(0, 0, 0, 0.3);
}

.kanban-card-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.kanban-card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* File list in modal */
.project-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: linear-gradient(90deg, rgba(22, 12, 40, 0.85) 0%, rgba(12, 8, 22, 0.75) 100%);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    margin-bottom: 6px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .project-file-item {
    background: var(--bg-secondary);
    box-shadow: none;
}

.project-file-name {
    text-decoration: none;
    color: var(--accent-magenta);
    font-weight: 500;
    transition: var(--transition);
}

.project-file-name:hover {
    color: #f5d0fe;
    text-decoration: underline;
}

[data-theme="light"] .project-file-name {
    color: var(--accent-purple);
}

[data-theme="light"] .project-file-name:hover {
    color: #5b21b6;
}

.project-file-delete {
    color: #ef4444;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Category manager rows (articles modal) */
.cat-mgr-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: linear-gradient(100deg, rgba(24, 14, 42, 0.75) 0%, rgba(12, 8, 22, 0.8) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .cat-mgr-item {
    background: var(--bg-secondary);
    box-shadow: none;
}

.cat-mgr-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--text-primary);
}

.cat-mgr-label strong {
    font-weight: 600;
    letter-spacing: 0.01em;
}

.cat-mgr-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* NOTES VIEW STYLES */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.note-card {
    background: linear-gradient(150deg, rgba(28, 18, 48, 0.9) 0%, rgba(14, 10, 26, 0.88) 100%);
    border-radius: 16px;
    padding: 20px 22px;
    border: 1px solid var(--border-color);
    transition: all 0.28s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    cursor: default;
    box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .note-card {
    background: var(--bg-secondary);
    box-shadow: var(--shadow-soft);
}

.note-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-glow), 0 12px 28px rgba(0, 0, 0, 0.35);
}

.note-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.note-content {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
    max-height: 150px;
    overflow-y: auto;
}

.note-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
}

.note-expiry {
    color: #ef4444;
}

.note-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    padding: 4px;
    border-radius: 4px;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: rgba(139, 92, 246, 0.18);
    color: var(--accent-magenta);
}

.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
}
/* MARKDOWN RENDER STYLES */
#modal-content-view { font-size: 16px; line-height: 1.7; color: var(--text-primary); }
#modal-content-view strong,
#modal-content-view b {
    font-weight: 700;
}
#modal-content-view em,
#modal-content-view i {
    font-style: italic;
}
#modal-content-view u {
    text-decoration: underline;
}
#modal-content-view s,
#modal-content-view del {
    text-decoration: line-through;
}
#modal-content-view h1, #modal-content-view h2, #modal-content-view h3 { margin-top: 24px; margin-bottom: 16px; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
#modal-content-view p { margin-bottom: 16px; }
#modal-content-view a {
    color: var(--accent-magenta);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: var(--transition);
}
#modal-content-view a:hover {
    color: #f5d0fe;
}
[data-theme="light"] #modal-content-view a {
    color: var(--accent-purple);
}
[data-theme="light"] #modal-content-view a:hover {
    color: #5b21b6;
}
#modal-content-view code {
    font-family: var(--code-font);
    background: rgba(167, 139, 250, 0.14);
    color: #ede9fe;
    border: 1px solid rgba(167, 139, 250, 0.22);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.9em;
}
#modal-content-view pre {
    background: linear-gradient(165deg, rgba(14, 8, 26, 0.98) 0%, rgba(8, 5, 16, 0.99) 100%);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 24px;
    overflow-x: auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 24px rgba(0, 0, 0, 0.35);
}
#modal-content-view pre.code-block-wrapper { position: relative; padding-top: 46px; }
#modal-content-view .code-copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    line-height: 1;
}
#modal-content-view .code-copy-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.15);
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.12);
}
#modal-content-view code.inline-copy-enabled {
    cursor: pointer;
}
#modal-content-view pre code { background: transparent; color: var(--text-primary); padding: 0; font-size: 14px; display: block; white-space: pre; }
#modal-content-view blockquote {
    border-left: 4px solid var(--accent-purple);
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.12) 0%, rgba(22, 14, 40, 0.55) 100%);
    padding: 16px 24px;
    margin: 24px 0;
    color: var(--text-secondary);
    font-style: italic;
    border-radius: 0 12px 12px 0;
    border: 1px solid var(--border-color);
    border-left-width: 4px;
}
#modal-content-view ul, #modal-content-view ol { margin-bottom: 24px; padding-left: 24px; }
#modal-content-view li { margin-bottom: 8px; }
#modal-content-view img { max-width: 100%; border-radius: 12px; margin: 24px 0; box-shadow: var(--shadow); }

[data-theme="light"] #modal-content-view code {
    background: rgba(124, 58, 237, 0.1);
    color: #5b21b6;
    border-color: rgba(124, 58, 237, 0.18);
}

[data-theme="light"] #modal-content-view pre {
    background: #f8fafc;
    box-shadow: none;
}

[data-theme="light"] #modal-content-view blockquote {
    background: rgba(124, 58, 237, 0.06);
    border-color: rgba(15, 23, 42, 0.08);
}

/* Toast: always above modals (.modal-overlay is z-index 2000) */
#toast.toast {
    position: fixed;
    top: max(16px, env(safe-area-inset-top, 0px));
    right: max(16px, env(safe-area-inset-right, 0px));
    z-index: 100000;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 14px 18px 14px 16px;
    font-family: var(--ui-font);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.45;
    color: var(--text-primary);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateX(calc(100% + 24px));
    transition:
        opacity 0.3s ease,
        transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0.42s;
}

#toast.toast .toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.55) 0%, rgba(192, 38, 211, 0.4) 100%);
    color: #faf5ff;
    border: 1px solid rgba(233, 213, 255, 0.25);
}

#toast.toast .toast-icon svg {
    display: block;
}

#toast.toast .toast-message {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
}

#toast.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
}

[data-theme="light"] #toast.toast {
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04) inset;
}

/* Scratchpad toolbar — 2 oszlop: felül két gomb, középen projekt, alul két gomb */
.scratchpad-toolbar {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
    align-items: stretch;
}

.scratchpad-toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 10px;
    white-space: nowrap;
    text-align: center;
}

.scratchpad-project-select {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    max-width: none;
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Projects agenda */
.projects-agenda {
    margin-bottom: 20px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: linear-gradient(145deg, rgba(24, 14, 42, 0.75) 0%, rgba(10, 6, 18, 0.85) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .projects-agenda {
    background: var(--bg-secondary);
}

.projects-agenda-empty {
    font-size: 14px;
    color: var(--text-secondary);
}

.projects-agenda-heading {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0 0 10px;
}

.projects-agenda-section + .projects-agenda-section {
    margin-top: 16px;
}

.projects-agenda-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.projects-agenda-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.projects-agenda-item:last-child {
    border-bottom: 0;
}

.projects-agenda-item--overdue .projects-agenda-meta {
    color: #f87171;
}

.projects-agenda-link {
    text-align: left;
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    padding: 6px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.projects-agenda-link:hover {
    border-color: var(--border-strong);
    background: rgba(139, 92, 246, 0.22);
}

.projects-agenda-meta {
    font-size: 12px;
    color: var(--text-secondary);
    padding-left: 2px;
}

.kanban-card-badges {
    font-size: 11px;
    color: var(--accent-magenta);
}

.kanban-card--archived {
    opacity: 0.55;
}

/* Article ↔ project links */
.article-linked-projects {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.article-linked-label {
    font-size: 12px;
    color: var(--text-secondary);
    width: 100%;
}

.article-linked-chip {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-magenta);
    cursor: pointer;
    transition: var(--transition);
}

.article-linked-chip:hover {
    background: rgba(139, 92, 246, 0.22);
    color: #f5d0fe;
}

.edit-linked-projects-wrap {
    flex: 1 1 200px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.edit-linked-projects-label {
    font-size: 11px;
    color: var(--text-secondary);
}

#edit-linked-projects {
    width: 100%;
    min-height: 88px;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.checkbox-inline input {
    accent-color: #7c3aed;
}

/* --- Desktop: full sidebar, hide drawer UI --- */
.sidebar-backdrop {
    display: none;
}

.sidebar-menu-btn {
    display: none;
}

.topbar-trailing {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

/* --- Mobile & small tablets --- */
@media (max-width: 900px) {
    body {
        height: 100dvh;
        min-height: 100dvh;
    }

    .app-container {
        position: relative;
        min-height: 100dvh;
        height: 100dvh;
        flex-direction: column;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 2500;
        background: rgba(2, 1, 8, 0.55);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.25s ease, visibility 0.25s ease;
    }

    .sidebar-backdrop.is-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    body.kb-mobile-nav-open {
        overflow: hidden;
    }

    #app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100dvh;
        height: -webkit-fill-available;
        max-height: 100dvh;
        width: min(300px, 88vw);
        max-width: 320px;
        z-index: 2600;
        transform: translateX(-102%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 8px 0 40px rgba(0, 0, 0, 0.5);
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    #app-sidebar.sidebar--open {
        transform: translateX(0);
    }

    .sidebar-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        border-radius: 12px;
        border: 1px solid var(--border-color);
        background: var(--bg-card);
        color: var(--text-primary);
        flex-shrink: 0;
    }

    .sidebar-menu-btn:active {
        transform: scale(0.96);
    }

    .main-content {
        flex: 1;
        min-width: 0;
        width: 100%;
        min-height: 0;
    }

    .topbar {
        display: grid;
        grid-template-columns: 44px 1fr;
        grid-template-rows: auto auto;
        gap: 10px 12px;
        align-items: center;
        height: auto;
        min-height: 56px;
        padding-top: max(10px, env(safe-area-inset-top, 0px));
        padding-bottom: 12px;
        padding-left: max(12px, env(safe-area-inset-left, 0px));
        padding-right: max(12px, env(safe-area-inset-right, 0px));
    }

    #sidebar-menu-btn {
        grid-column: 1;
        grid-row: 1;
    }

    #topbar-search-slot {
        grid-column: 2;
        grid-row: 1;
        min-width: 0;
        max-width: none;
    }

    #topbar-search-slot .search-container {
        min-width: 0;
        max-width: none;
    }

    .topbar-trailing {
        grid-column: 1 / -1;
        grid-row: 2;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
        gap: 10px;
        width: 100%;
    }

    #new-article-btn.btn-primary,
    #new-learning-card-btn.btn-primary {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: center;
        padding-inline: 14px;
        min-height: 44px;
    }

    .theme-toggle {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .search-container input#search-input {
        min-height: 44px;
        font-size: 16px;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .search-clear-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    .content-area {
        padding: 18px 14px 28px;
        padding-bottom: max(28px, env(safe-area-inset-bottom, 0px));
    }

    .article-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .article-card {
        padding: 20px 18px;
    }

    .article-card:active {
        transform: translateY(-2px);
    }

    .notes-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 12px 0;
    }

    .note-card {
        padding: 18px 16px;
    }

    .kanban-board {
        height: auto;
        min-height: 45vh;
        max-height: none;
        padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
    }

    .kanban-column {
        flex: 0 0 min(300px, 86vw);
    }

    .projects-agenda {
        padding: 14px 12px;
    }

    .login-screen {
        padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-left, 0px))
            max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-right, 0px));
    }

    .login-card {
        padding: 40px 24px;
        max-width: calc(100vw - 32px);
        margin: 0 auto;
    }

    .login-header h2 {
        font-size: 24px;
    }

    .modal-overlay {
        z-index: 2700;
        align-items: stretch;
        justify-content: stretch;
        padding: max(8px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-left, 0px))
            max(8px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-right, 0px));
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: min(92dvh, 100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px);
        border-radius: 18px;
        margin: auto 0;
    }

    .modal-header {
        padding: 20px 18px 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .modal-body {
        padding: 20px 16px;
    }

    .modal-footer {
        padding: 16px 18px 20px;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: stretch;
    }

    .modal-footer .btn-primary,
    .modal-footer .btn-secondary,
    .modal-footer .btn-danger {
        flex: 1 1 auto;
        min-height: 44px;
        justify-content: center;
    }

    .modal-close {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    #modal-edit-header {
        flex-direction: column;
        align-items: stretch !important;
    }

    #modal-edit-header #edit-title,
    #modal-edit-header #edit-category {
        width: 100%;
    }

    .editor-toolbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 0;
    }

    .toolbar-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    #edit-content {
        min-height: 220px;
        height: min(50vh, 360px);
    }

    .sidebar-header {
        padding: 24px 18px 16px;
    }

    .sidebar-nav {
        padding: 0 12px;
    }

    .sidebar-nav .nav-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .scratchpad-toolbar {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .scratchpad-toolbar-btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .scratchpad-project-select {
        min-height: 44px;
    }

    #scratchpad {
        min-height: 120px;
        font-size: 16px;
    }

    .logout-btn {
        min-height: 48px;
    }
}

@media (max-width: 900px) and (hover: hover) {
    .article-card:active {
        transform: translateY(-6px);
    }
}
