/* ===== Reset & Variables ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --clr-bg: #f4f5f7;
    --clr-surface: #ffffff;
    --clr-sidebar: #fafbfc;
    --clr-primary: #4f6ef7;
    --clr-primary-light: #eaf0fb;
    --clr-primary-hover: #3b57d9;
    --clr-danger: #e74c3c;
    --clr-danger-hover: #c0392b;
    --clr-success: #27ae60;
    --clr-success-light: #e8f8f0;
    --clr-warning: #f39c12;
    --clr-warning-light: #fef5e7;
    --clr-danger-light: #fdecea;
    --clr-text: #1e293b;
    --clr-text-secondary: #64748b;
    --clr-text-muted: #94a3b8;
    --clr-border: #e2e8f0;
    --clr-border-light: #f1f5f9;
    --clr-shadow: rgba(0, 0, 0, 0.06);
    --clr-shadow-lg: rgba(0, 0, 0, 0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-xs: 4px;
    --transition: 0.15s ease;
    --sidebar-w: 360px;
    --topbar-h: 56px;
    --footer-h: 40px;
    --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: var(--font-main);
    background: var(--clr-bg);
    color: var(--clr-text);
    line-height: 1.55;
    height: 100vh;
    overflow: hidden;
    padding-bottom: var(--footer-h);
}

/* ===== Auth Overlay ===== */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #eaf0fb 0%, #f4f5f7 50%, #e8f8f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    animation: fadeIn 0.3s ease;
}

.auth-card {
    background: var(--clr-surface);
    border-radius: 16px;
    padding: 40px 36px;
    width: 92%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--clr-border-light);
    text-align: center;
}

.auth-logo {
    font-size: 2rem;
    font-weight: 800;
    color: var(--clr-primary);
    margin-bottom: 4px;
}

.auth-subtitle {
    font-size: 0.9rem;
    color: var(--clr-text-muted);
    margin-bottom: 28px;
}

.auth-form .form-group {
    text-align: left;
    margin-bottom: 14px;
}

.auth-form .form-group label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--clr-text-secondary);
    margin-bottom: 5px;
    display: block;
}

.auth-form .form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--clr-border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font-main);
    outline: none;
    transition: border-color var(--transition);
    background: var(--clr-surface);
    color: var(--clr-text);
}

.auth-form .form-group input:focus {
    border-color: var(--clr-primary);
}

.btn-full {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
    margin-top: 8px;
}

.auth-switch {
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--clr-text-muted);
}

.auth-switch a {
    color: var(--clr-primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-error {
    background: var(--clr-danger-light);
    color: var(--clr-danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-top: 8px;
    text-align: left;
}

/* ===== User Info (Topbar) ===== */
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--clr-border-light);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--clr-primary);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--clr-text);
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Top Bar ===== */
.topbar {
    height: var(--topbar-h);
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    position: relative;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--clr-primary);
    white-space: nowrap;
}

.topbar-center {
    flex: 1;
    max-width: 420px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--clr-bg);
    border-radius: var(--radius);
    padding: 0 12px;
    border: 1.5px solid transparent;
    transition: border-color var(--transition), background var(--transition);
}

.search-box:focus-within {
    border-color: var(--clr-primary);
    background: var(--clr-surface);
}

.search-icon {
    font-size: 0.85rem;
    margin-right: 8px;
    color: var(--clr-text-muted);
}

.search-box input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.9rem;
    font-family: var(--font-main);
    padding: 9px 0;
    width: 100%;
    color: var(--clr-text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats-pills {
    display: flex;
    gap: 6px;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.pill-total   { background: var(--clr-primary-light); color: var(--clr-primary); }
.pill-active  { background: var(--clr-warning-light); color: var(--clr-warning); }
.pill-done    { background: var(--clr-success-light); color: var(--clr-success); }

/* ===== App Layout (Sidebar + Detail) ===== */
.app-layout {
    display: flex;
    height: calc(100vh - var(--topbar-h) - var(--footer-h));
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--clr-sidebar);
    border-right: 1px solid var(--clr-border);
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s ease, opacity 0.25s ease;
}

.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-w));
    opacity: 0;
    pointer-events: none;
}

.sidebar-top {
    padding: 14px 14px 0;
}

/* Quick Add */
.quick-add {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.quick-add input {
    flex: 1;
    padding: 10px 12px;
    border: 2px dashed var(--clr-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font-main);
    outline: none;
    transition: all var(--transition);
    background: var(--clr-surface);
    cursor: pointer;
    color: var(--clr-text-muted);
}

.quick-add input:hover {
    border-color: var(--clr-primary);
    background: var(--clr-primary-light);
    color: var(--clr-primary);
}

.quick-add input:focus {
    border-color: var(--clr-primary);
}

/* Sidebar Filters */
.sidebar-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.sidebar-filters select {
    flex: 1;
    min-width: 0;
    padding: 7px 8px;
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-xs);
    font-size: 0.78rem;
    font-family: var(--font-main);
    background: var(--clr-surface);
    color: var(--clr-text);
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition);
}

.sidebar-filters select:focus {
    border-color: var(--clr-primary);
}

/* Sidebar Task List */
.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px 10px;
}

.sidebar-list::-webkit-scrollbar {
    width: 5px;
}

.sidebar-list::-webkit-scrollbar-thumb {
    background: var(--clr-border);
    border-radius: 4px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--clr-text-muted);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--clr-border-light);
    display: flex;
    justify-content: flex-end;
}

/* ===== Sidebar Task Cards ===== */
.task-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
    border: 1.5px solid transparent;
    margin-bottom: 4px;
}

.task-card:hover {
    background: var(--clr-surface);
    box-shadow: 0 1px 6px var(--clr-shadow);
}

.task-card.selected {
    background: var(--clr-primary-light);
    border-color: var(--clr-primary);
}

.task-card.completed-card .card-title {
    text-decoration: line-through;
    color: var(--clr-text-muted);
}

/* Card Checkbox */
.card-check {
    margin-top: 2px;
    flex-shrink: 0;
}

.mini-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--clr-border);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    display: block;
}

.mini-checkbox:checked {
    background: var(--clr-success);
    border-color: var(--clr-success);
}

.mini-checkbox:checked::after {
    content: '\2713';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

.mini-checkbox:hover {
    border-color: var(--clr-success);
}

/* Card Content */
.card-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-subtitle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.card-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-high    { background: var(--clr-danger-light);  color: var(--clr-danger); }
.badge-medium  { background: var(--clr-warning-light); color: var(--clr-warning); }
.badge-low     { background: var(--clr-success-light); color: var(--clr-success); }
.badge-cat     { background: var(--clr-primary-light); color: var(--clr-primary); }
.badge-due     { background: var(--clr-border-light);  color: var(--clr-text-muted); font-size: 0.62rem; }
.badge-due.overdue { background: var(--clr-danger-light); color: var(--clr-danger); }
.badge-shared  { background: #e8eaf6; color: #5c6bc0; }

/* Shared task card styling */
.task-card.shared-card {
    border-left: 3px solid #5c6bc0;
}

/* Priority dot */
.priority-dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    border-radius: 50%;
    margin-top: 6px;
}

.dot-high   { background: var(--clr-danger); }
.dot-medium { background: var(--clr-warning); }
.dot-low    { background: var(--clr-success); }

/* ===== Detail Panel ===== */
.detail-panel {
    flex: 1;
    overflow-y: auto;
    background: var(--clr-surface);
    position: relative;
}

.detail-panel::-webkit-scrollbar {
    width: 6px;
}

.detail-panel::-webkit-scrollbar-thumb {
    background: var(--clr-border);
    border-radius: 4px;
}

/* Detail Empty */
.detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--clr-text-muted);
    text-align: center;
    padding: 40px;
}

.detail-empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.detail-empty h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--clr-text-secondary);
    margin-bottom: 6px;
}

.detail-empty p {
    font-size: 0.95rem;
}

/* Detail View */
.detail-view {
    padding: 32px 40px;
    max-width: 760px;
    animation: detailIn 0.2s ease;
}

@keyframes detailIn {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}

.detail-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 28px;
}

.detail-check {
    margin-top: 4px;
}

.detail-title-wrap {
    flex: 1;
    min-width: 0;
}

.detail-title {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.3;
    word-break: break-word;
}

.detail-title.done {
    text-decoration: line-through;
    color: var(--clr-text-muted);
}

.detail-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.detail-badges .card-badge {
    font-size: 0.7rem;
    padding: 2px 10px;
}

.detail-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* Detail Meta */
.detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.meta-card {
    background: var(--clr-bg);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}

.meta-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--clr-text-muted);
    font-weight: 700;
    margin-bottom: 4px;
}

.meta-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--clr-text);
}

.meta-value.overdue {
    color: var(--clr-danger);
}

/* Quick Copy Section */
.quick-copy-section {
    margin-bottom: 32px;
}

.quick-copy-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--clr-text-muted);
    font-weight: 700;
    margin-bottom: 12px;
}

.copy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.copy-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--clr-bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
    border: 1.5px solid transparent;
}

.copy-item:hover {
    background: var(--clr-primary-light);
    border-color: var(--clr-primary);
}

.copy-item-icon {
    font-size: 1rem;
    color: var(--clr-primary);
    flex-shrink: 0;
}

.copy-item-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
}

.copy-item-action {
    font-size: 0.7rem;
    color: var(--clr-primary);
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--transition);
}

.copy-item:hover .copy-item-action {
    opacity: 1;
}

/* Detail Footer */
.detail-footer {
    border-top: 1px solid var(--clr-border-light);
    padding-top: 16px;
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--clr-text-muted);
}

.detail-footer span {
    white-space: nowrap;
}

/* ===== Edit Mode (inline) ===== */
.detail-edit {
    padding: 32px 40px;
    max-width: 760px;
    animation: detailIn 0.2s ease;
}

.edit-heading {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--clr-text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--clr-border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font-main);
    outline: none;
    transition: border-color var(--transition);
    background: var(--clr-surface);
    color: var(--clr-text);
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--clr-primary);
}

.form-row {
    display: flex;
    gap: 14px;
}

.form-row .form-group {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s;
    font-family: var(--font-main);
}

.btn:active { transform: scale(0.97); }

.btn-primary   { background: var(--clr-primary); color: #fff; }
.btn-primary:hover { background: var(--clr-primary-hover); }
.btn-secondary { background: var(--clr-border); color: var(--clr-text); }
.btn-secondary:hover { background: #c8cdd5; }
.btn-danger    { background: var(--clr-danger); color: #fff; }
.btn-danger:hover { background: var(--clr-danger-hover); }
.btn-ghost     { background: transparent; color: var(--clr-text-secondary); border: 1px solid var(--clr-border); }
.btn-ghost:hover { background: var(--clr-bg); }
.btn-sm        { padding: 5px 12px; font-size: 0.78rem; }

.icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    font-size: 1.05rem;
    color: var(--clr-text-secondary);
    transition: background var(--transition), color var(--transition);
}

.icon-btn:hover {
    background: var(--clr-bg);
    color: var(--clr-text);
}

.btn-add {
    background: var(--clr-primary);
    color: #fff;
    font-size: 1.3rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
}

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

.btn-icon-danger:hover {
    color: var(--clr-danger);
    background: var(--clr-danger-light);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal {
    background: var(--clr-surface);
    border-radius: var(--radius);
    width: 92%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: modalSlide 0.2s ease;
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

.modal-header h2 { font-size: 1.05rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--clr-text-muted);
    line-height: 1;
    padding: 0 4px;
}

.modal-close:hover { color: var(--clr-text); }

.modal-body { padding: 20px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--clr-border-light); }

/* ===== Notification ===== */
.notification {
    position: fixed;
    bottom: calc(var(--footer-h) + 16px);
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    z-index: 2000;
    animation: notifSlide 0.25s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
    max-width: 340px;
}

.notification.success { background: var(--clr-success); }
.notification.error   { background: var(--clr-danger); }
.notification.info    { background: var(--clr-primary); }

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
    :root {
        --sidebar-w: 100vw;
    }

    .sidebar {
        position: fixed;
        top: var(--topbar-h);
        left: 0;
        bottom: var(--footer-h);
        z-index: 90;
        box-shadow: 4px 0 20px rgba(0,0,0,0.12);
    }

    .sidebar.collapsed {
        margin-left: -100vw;
    }

    .detail-view,
    .detail-edit {
        padding: 20px 16px;
    }

    .detail-title {
        font-size: 1.3rem;
    }

    .detail-header {
        flex-wrap: wrap;
    }

    .detail-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 8px;
    }

    .copy-grid {
        grid-template-columns: 1fr;
    }

    .topbar-center {
        display: none;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

@media (min-width: 769px) {
    #sidebar-toggle {
        display: none;
    }
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(2px);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--clr-border);
    border-top-color: var(--clr-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Subtle loading state for sidebar */
.app-loading .sidebar-list {
    opacity: 0.5;
    pointer-events: none;
}

/* Checkbox styling in detail panel */
.task-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    min-width: 24px;
    border: 2.5px solid var(--clr-border);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    display: block;
}

.task-checkbox:checked {
    background: var(--clr-success);
    border-color: var(--clr-success);
}

.task-checkbox:checked::after {
    content: '\2713';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.task-checkbox:hover {
    border-color: var(--clr-success);
}

/* ===== Markdown Notes Section ===== */
.notes-section {
    margin-bottom: 28px;
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--clr-bg);
}

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

.notes-header h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--clr-text-muted);
    font-weight: 700;
    margin: 0;
}

.notes-toggle {
    display: flex;
    gap: 2px;
    background: var(--clr-bg);
    border-radius: var(--radius-xs);
    padding: 2px;
}

.notes-tab {
    padding: 5px 14px;
    border: none;
    border-radius: var(--radius-xs);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-main);
    cursor: pointer;
    background: transparent;
    color: var(--clr-text-secondary);
    transition: all var(--transition);
}

.notes-tab.active {
    background: var(--clr-surface);
    color: var(--clr-primary);
    box-shadow: 0 1px 3px var(--clr-shadow);
}

.notes-tab:hover:not(.active) {
    color: var(--clr-text);
}

.notes-editor {
    position: relative;
}

.notes-textarea {
    width: 100%;
    min-height: 280px;
    padding: 16px;
    border: none;
    outline: none;
    resize: vertical;
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--clr-text);
    background: transparent;
    tab-size: 4;
}

.notes-textarea::placeholder {
    color: var(--clr-text-muted);
    font-style: italic;
}

.notes-textarea:focus {
    background: rgba(79, 110, 247, 0.02);
}

.notes-preview {
    min-height: 280px;
    padding: 16px 20px;
    max-height: 600px;
    overflow-y: auto;
}

.notes-preview::-webkit-scrollbar {
    width: 5px;
}

.notes-preview::-webkit-scrollbar-thumb {
    background: var(--clr-border);
    border-radius: 4px;
}

.notes-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-top: 1px solid var(--clr-border-light);
    background: var(--clr-surface);
}

.notes-hint {
    font-size: 0.72rem;
    color: var(--clr-text-muted);
    font-style: italic;
}

.notes-charcount {
    font-size: 0.72rem;
    color: var(--clr-text-muted);
    font-variant-numeric: tabular-nums;
}

/* ===== Markdown Rendered Body ===== */
.markdown-body {
    font-family: var(--font-main);
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--clr-text);
    word-wrap: break-word;
}

.markdown-body > *:first-child {
    margin-top: 0;
}

.markdown-body > *:last-child {
    margin-bottom: 0;
}

.markdown-body h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--clr-border);
    color: var(--clr-text);
}

.markdown-body h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 20px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--clr-border-light);
    color: var(--clr-text);
}

.markdown-body h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 16px 0 8px;
    color: var(--clr-text);
}

.markdown-body h4 {
    font-size: 1rem;
    font-weight: 700;
    margin: 14px 0 6px;
    color: var(--clr-text);
}

.markdown-body h5, .markdown-body h6 {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 12px 0 6px;
    color: var(--clr-text-secondary);
}

.markdown-body p {
    margin: 0 0 12px;
}

.markdown-body ul, .markdown-body ol {
    margin: 0 0 12px;
    padding-left: 28px;
}

.markdown-body li {
    margin: 4px 0;
}

.markdown-body li > ul, .markdown-body li > ol {
    margin-bottom: 0;
}

.markdown-body blockquote {
    margin: 0 0 12px;
    padding: 8px 16px;
    border-left: 4px solid var(--clr-primary);
    background: var(--clr-primary-light);
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
    color: var(--clr-text-secondary);
}

.markdown-body blockquote p:last-child {
    margin-bottom: 0;
}

.markdown-body code {
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
    font-size: 0.84em;
    background: var(--clr-bg);
    color: var(--clr-danger);
    border: 1px solid var(--clr-border-light);
}

.markdown-body pre {
    margin: 0 0 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: #1e293b;
    overflow-x: auto;
    border: 1px solid var(--clr-border);
}

.markdown-body pre code {
    padding: 0;
    border: none;
    background: none;
    color: #e2e8f0;
    font-size: 0.84em;
    line-height: 1.55;
}

.markdown-body a {
    color: var(--clr-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition);
}

.markdown-body a:hover {
    border-bottom-color: var(--clr-primary);
}

.markdown-body hr {
    border: none;
    border-top: 2px solid var(--clr-border);
    margin: 20px 0;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 12px;
}

.markdown-body th, .markdown-body td {
    padding: 8px 12px;
    border: 1px solid var(--clr-border);
    text-align: left;
}

.markdown-body th {
    background: var(--clr-bg);
    font-weight: 700;
    font-size: 0.84rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.markdown-body img {
    max-width: 100%;
    border-radius: var(--radius-sm);
}

.markdown-body input[type="checkbox"] {
    margin-right: 6px;
}

.markdown-body del {
    color: var(--clr-text-muted);
}

/* ===== Form Textarea ===== */
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--clr-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
    line-height: 1.6;
    outline: none;
    transition: border-color var(--transition);
    background: var(--clr-surface);
    color: var(--clr-text);
    resize: vertical;
}

.form-textarea:focus {
    border-color: var(--clr-primary);
}

.form-textarea::placeholder {
    color: var(--clr-text-muted);
    font-style: italic;
}

.label-hint {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--clr-text-muted);
    text-transform: none;
    letter-spacing: 0;
}

/* ===== Notes Copy Button ===== */
.notes-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.notes-copy-btn {
    padding: 4px 10px;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-xs);
    background: var(--clr-surface);
    color: var(--clr-text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.notes-copy-btn:hover {
    background: var(--clr-primary-light);
    border-color: var(--clr-primary);
    color: var(--clr-primary);
}

/* ===== Share Modal ===== */
.share-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.share-info {
    font-size: 0.82rem;
    color: var(--clr-text-muted);
    margin-bottom: 10px;
    font-weight: 600;
}

.share-list {
    max-height: 280px;
    overflow-y: auto;
}

.share-empty {
    text-align: center;
    padding: 20px;
    color: var(--clr-text-muted);
    font-size: 0.88rem;
}

.share-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border-bottom: 1px solid var(--clr-border-light);
    transition: background var(--transition);
}

.share-item:last-child {
    border-bottom: none;
}

.share-item:hover {
    background: var(--clr-bg);
}

.share-item-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #5c6bc0;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.share-item-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--clr-text);
}

/* ── Share username typeahead ────────────────────────── */
.share-input-wrap {
    flex: 1;
    position: relative;
}

.share-form input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--clr-border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: var(--font-main);
    outline: none;
    transition: border-color var(--transition);
    background: var(--clr-surface);
    color: var(--clr-text);
}

.share-form input[type="text"]:focus {
    border-color: var(--clr-primary);
}

.share-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: 0 8px 24px var(--clr-shadow-lg);
    z-index: 100;
    max-height: 220px;
    overflow-y: auto;
}

.share-suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid var(--clr-border-light);
}

.share-suggestion-item:last-child {
    border-bottom: none;
}

.share-suggestion-item:hover,
.share-suggestion-item.active {
    background: var(--clr-primary-light);
}

.share-suggestion-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--clr-primary);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.share-suggestion-name {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--clr-text);
}

/* ===== Category Manager Modal ===== */
.modal-wide {
    max-width: 560px;
}

.cat-add-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.cat-add-form input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--clr-border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: var(--font-main);
    outline: none;
    transition: border-color var(--transition);
    background: var(--clr-surface);
    color: var(--clr-text);
}

.cat-add-form input[type="text"]:focus {
    border-color: var(--clr-primary);
}

.cat-color-input {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 2px;
    border: 2px solid var(--clr-border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    background: var(--clr-surface);
}

.cat-color-input::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.cat-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.cat-list {
    max-height: 380px;
    overflow-y: auto;
}

.cat-list::-webkit-scrollbar {
    width: 5px;
}

.cat-list::-webkit-scrollbar-thumb {
    background: var(--clr-border);
    border-radius: 4px;
}

.cat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    border-bottom: 1px solid var(--clr-border-light);
}

.cat-item:last-child {
    border-bottom: none;
}

.cat-item:hover {
    background: var(--clr-bg);
}

.cat-color-dot {
    width: 14px;
    height: 14px;
    min-width: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cat-item-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--clr-text);
}

.cat-item-name-input {
    flex: 1;
    padding: 4px 8px;
    border: 2px solid var(--clr-primary);
    border-radius: var(--radius-xs);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-main);
    outline: none;
    background: var(--clr-surface);
    color: var(--clr-text);
}

.cat-item-color-input {
    width: 28px;
    height: 28px;
    min-width: 28px;
    padding: 1px;
    border: 2px solid var(--clr-border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    background: var(--clr-surface);
}

.cat-item-color-input::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.cat-item-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.cat-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.cat-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all var(--transition);
    background: transparent;
    color: var(--clr-text-muted);
}

.cat-btn:hover {
    background: var(--clr-bg);
    color: var(--clr-text);
}

.cat-btn.cat-btn-danger:hover {
    color: var(--clr-danger);
    background: var(--clr-danger-light);
}

.cat-btn.cat-btn-save {
    color: var(--clr-success);
}

.cat-btn.cat-btn-save:hover {
    background: var(--clr-success-light);
}

/* Category dot in sidebar badge */
.badge-cat-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

/* ===== Notification Bell & Dropdown ===== */
.notif-bell-wrap {
    position: relative;
    display: inline-flex;
}

.notif-bell-btn {
    position: relative;
    font-size: 1.15rem;
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--clr-danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(231, 76, 60, 0.4);
    animation: badgePop 0.25s ease;
}

@keyframes badgePop {
    0%   { transform: scale(0.5); opacity: 0; }
    60%  { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    background: var(--clr-surface);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 0 0 1px var(--clr-border-light);
    z-index: 200;
    animation: notifDrop 0.18s ease;
    overflow: hidden;
}

@keyframes notifDrop {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--clr-border-light);
    background: var(--clr-surface);
}

.notif-dropdown-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--clr-text);
}

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

.notif-action-btn {
    background: none;
    border: none;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--clr-primary);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    transition: background var(--transition), color var(--transition);
    font-family: var(--font-main);
}

.notif-action-btn:hover {
    background: var(--clr-primary-light);
}

.notif-action-danger {
    color: var(--clr-danger);
}

.notif-action-danger:hover {
    background: var(--clr-danger-light);
}

.notif-dropdown-list {
    max-height: 360px;
    overflow-y: auto;
}

.notif-dropdown-list::-webkit-scrollbar {
    width: 5px;
}

.notif-dropdown-list::-webkit-scrollbar-thumb {
    background: var(--clr-border);
    border-radius: 4px;
}

.notif-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--clr-text-muted);
    font-size: 0.88rem;
}

.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--clr-border-light);
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-item:hover {
    background: var(--clr-bg);
}

.notif-item.unread {
    background: var(--clr-primary-light);
}

.notif-item.unread:hover {
    background: #dce5fa;
}

.notif-item-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.notif-item-icon.notif-type-shared {
    background: #e8eaf6;
    color: #5c6bc0;
}

.notif-item-icon.notif-type-changed {
    background: var(--clr-warning-light);
    color: var(--clr-warning);
}

.notif-item-body {
    flex: 1;
    min-width: 0;
}

.notif-item-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--clr-text);
    line-height: 1.3;
    margin-bottom: 2px;
}

.notif-item-message {
    font-size: 0.78rem;
    color: var(--clr-text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-item-time {
    font-size: 0.65rem;
    color: var(--clr-text-muted);
    margin-top: 3px;
    white-space: nowrap;
}

.notif-item-dot {
    position: absolute;
    top: 14px;
    right: 12px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--clr-primary);
}

.notif-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    align-self: center;
}

.notif-item-dismiss {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--clr-text-muted);
    cursor: pointer;
    font-size: 0.7rem;
    transition: all var(--transition);
    opacity: 0;
}

.notif-item:hover .notif-item-dismiss {
    opacity: 1;
}

.notif-item-dismiss:hover {
    background: var(--clr-danger-light);
    color: var(--clr-danger);
}

/* Markdown notes responsive */
@media (max-width: 768px) {
    .notes-textarea {
        min-height: 200px;
    }
    .notes-preview {
        min-height: 200px;
    }
    .cat-add-form {
        flex-wrap: wrap;
    }
    .cat-add-form input[type="text"] {
        min-width: 0;
    }
    .auth-card {
        padding: 28px 20px;
    }
    .user-name {
        display: none;
    }
    .share-form {
        flex-wrap: wrap;
    }
    .sidebar-filters select {
        min-width: calc(50% - 3px);
    }
    .notif-dropdown {
        position: fixed;
        top: var(--topbar-h);
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        max-height: calc(100vh - var(--topbar-h));
    }
}

/* ===== Sticky Footer Banner ===== */
.toolhub-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-h);
    background: var(--clr-surface);
    border-top: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 0.78rem;
    color: var(--clr-text-muted);
    z-index: 200;
    user-select: none;
}

.toolhub-footer a {
    color: var(--clr-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition);
}

.toolhub-footer a:hover {
    color: var(--clr-primary-hover);
    text-decoration: underline;
}

.toolhub-footer .separator {
    color: var(--clr-border);
    user-select: none;
}
