:root {
    /* Core palette */
    --bg: #f5f5f5;
    --text: #333333;
    --text-primary: #2c3e50;
    --text-secondary: #6c757d;

    --primary: #2196f3;
    --primary-600: #1976d2;
    --secondary: #673ab7;
    --secondary-600: #5e35b1;
    --accent: #9c27b0;
    --accent-600: #7b1fa2;
    --success: #4CAF50;
    --danger: #f44336;
    --warning: #ff9800;

    --border-color: #e0e0e0;
    --card-bg: #ffffff;
    --muted: #f6f8fa;
    --toast-bg: #323232;

    /* Back-compat alias */
    --primary-color: var(--primary);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

.container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 300px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 20px;
}

.sidebar h1 {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.sidebar-actions {
    margin-bottom: 20px;
}

.btn-tasks {
    display: block;
    width: 100%;
    padding: 10px;
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    background: var(--secondary);
}

.btn-tasks:hover {
    background: var(--secondary-600);
}

.btn-docs {
    display: block;
    width: 100%;
    padding: 10px;
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    margin-bottom: 8px;
    background: var(--primary);
}

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

.file-tree {
    font-size: 14px;
}

.tree-item {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 2px;
    user-select: none;
}

.tree-item:hover {
    background: #f0f0f0;
}

.tree-item.active {
    background: var(--primary-600);
    color: white;
    font-weight: 500;
}

.tree-directory {
    font-weight: 600;
}

.tree-directory::before {
    content: '▶ ';
    display: inline-block;
    transition: transform 0.2s;
    margin-right: 5px;
    color: #55c;
    font-size: 10px;
}

.tree-directory.expanded::before {
    transform: rotate(90deg);
}

.tree-children {
    padding-left: 20px;
    display: none;
}

.tree-children.expanded {
    display: block;
}

.content {
    flex: 1;
    padding: 20px 40px;
    overflow-y: auto;
    background: var(--card-bg);
    margin: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.toolbar h2 {
    color: var(--text-primary);
    font-size: 20px;
}

.toolbar-actions {
    display: flex;
    gap: 12px;
}

.btn-media, .btn-new-task {
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

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

.btn-media:hover {
    background: var(--accent-600);
}

.btn-new-task {
    background: var(--warning);
}

.btn-new-task:hover {
    opacity: 0.9;
}

.markdown-viewer {
    max-width: 900px;
}

.markdown-viewer h1, .markdown-viewer h2, .markdown-viewer h3 {
    margin-top: 24px;
    margin-bottom: 16px;
}

.markdown-viewer h1 {
    font-size: 28px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 8px;
}

.markdown-viewer h2 {
    font-size: 24px;
}

.markdown-viewer h3 {
    font-size: 20px;
}

.markdown-viewer p {
    margin-bottom: 16px;
}

.markdown-viewer pre {
    background: var(--muted);
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.markdown-viewer code {
    background: var(--muted);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
}

.markdown-viewer pre code {
    background: none;
    padding: 0;
}

.markdown-viewer ul, .markdown-viewer ol {
    margin-bottom: 16px;
    padding-left: 30px;
}

.markdown-viewer li {
    margin-bottom: 4px;
}

.btn-primary, .btn-secondary {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

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

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

.editor {
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
}

.edit-content {
    flex: 1;
    width: 100%;
    padding: 16px;
    height: 30rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.btn-edit, .btn-save, .btn-cancel {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-left: 8px;
}

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

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

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

.btn-secondary {
    background: #757575;
    color: white;
}

.btn-secondary:hover {
    background: #616161;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--toast-bg);
    color: white;
    padding: 16px 24px;
    border-radius: 4px;
    display: none;
    animation: slideIn 0.3s ease;
}

.toast.show {
    display: block;
}

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

.loading {
    text-align: center;
    color: #666;
    padding: 20px;
}

.media-library {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 1000px;
    max-height: 80vh;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.media-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.media-header h3 {
    margin: 0;
    color: #2c3e50;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.btn-close:hover {
    background: #f0f0f0;
}

.media-upload {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.media-grid {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.media-breadcrumb {
    padding: 10px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.breadcrumb-item {
    color: #2196f3;
    cursor: pointer;
    text-decoration: underline;
}

.breadcrumb-item:hover {
    color: #1976d2;
}

.folder-actions {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

.folder-actions button {
    padding: 8px 16px;
    font-size: 14px;
}

.media-grid > .media-item,
.media-grid > .folder {
    display: inline-block;
    vertical-align: top;
    width: 200px;
    margin: 8px;
}

.media-item {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px;
    text-align: center;
    transition: all 0.2s;
    position: relative;
}

.media-item.folder {
    cursor: pointer;
}

.media-item:hover {
    border-color: #2196f3;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.media-item .folder-icon {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.media-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 8px;
}

.media-item .media-select {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 20px;
    height: 20px;
}

.media-item .media-name {
    font-size: 12px;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-item .media-actions {
    margin-top: 8px;
    display: flex;
    gap: 4px;
    justify-content: center;
}

.media-item button {
    font-size: 11px;
    padding: 3px 6px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.media-item button:hover {
    background: #1976d2;
}

.media-item button.btn-danger {
    background: #f44336;
}

.media-item button.btn-danger:hover {
    background: #d32f2f;
}

.task-metadata {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}

.task-metadata h4 {
    margin: 0 0 12px 0;
    color: #495057;
    font-size: 16px;
}

.metadata-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.metadata-grid div {
    font-size: 14px;
    line-height: 1.4;
}

.metadata-grid strong {
    color: #343a40;
}

.priority-urgent {
    background: #ffebee;
    color: #c62828;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.priority-high {
    background: #fff3e0;
    color: #e65100;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.priority-normal {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.priority-low {
    background: #e3f2fd;
    color: #1565c0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-todo {
    background: #f5f5f5;
    color: #616161;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-in_progress {
    background: #fff8e1;
    color: #f57c00;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-done {
    background: #e8f5e9;
    color: #388e3c;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.points-badge {
    background: #e1bee7;
    color: #6a1b9a;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.version-badge {
    background: #b3e5fc;
    color: #0277bd;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.user-info {
    margin-bottom: 20px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.user-info small {
    display: block;
    color: #6c757d;
    font-size: 12px;
    margin-bottom: 8px;
}

.btn-logout {
    background: #6c757d;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.btn-logout:hover {
    background: #5a6268;
}

/* Top navigation */
.topnav {
    width: 100%;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    padding: 10px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topnav .brand a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
}

.topnav .links { margin-left: 8px; }
.topnav .links a {
    margin-left: 12px;
    color: var(--primary-600);
    text-decoration: none;
    font-weight: 500;
}

.topnav .links a:hover {
    text-decoration: underline;
}

.topnav .links a.active {
    color: var(--text-primary);
    border-bottom: 2px solid var(--primary);
}

li:has(input[type=checkbox]) {
  list-style: none;
  padding: 8px 6px;
}


li:has(input[type=checkbox]:checked) {
  text-decoration: line-through;
}

li:has(input[type=checkbox]):nth-child(2n+1) {
  background: #f9f9f9;
}

img {
  max-width: 100%;
}
